c# - Is there any way to clone array with value type, without create new
reference type?
i'm new to c# with python background.
In python, i can do this way:
a = {1, 5, 10} #initialize
a = {1, 3, 5} #change the value
How can i perform a = {1, 3, 5} on c#? Currently i found this way.
int[] a = {1, 5, 10}; //initialize
int[] b = {1 ,3, 5}; //create new reference type
a = (int[])b.Clone(); //change the value
Is there any better way to achieve the same goal? i.e. a = {1, 3, 5} on
python to C#?
No comments:
Post a Comment