What "new" means
Ive been thinking about what the real meaning of "new" in c#
the basic meaning that i have is when you use the new command it means a new location at the memory, like this example
Mobile a = new Mobile();
Mobile b = a;
b.Name = "foo";
this means, that i will create a new mobile a then set another reference to mobile a, wich will be called b, so when i set b.Name = "foo" it will also modify the Name in a, right?
so what i want, is to create 2 identical Mobiles, but with different names
Mobile a = new Mobile();
Mobile b = new Mobile();
b = a;
b.Name = "foo";
this will not work, because when you set b = a it will also reference the memory pointer from a to b
so, how i create 2 identical mobiles but with different names, not one Mobile with two references?
Will i have to copy each attribute like Name, Str..one by one ?
Ive been thinking about what the real meaning of "new" in c#
the basic meaning that i have is when you use the new command it means a new location at the memory, like this example
Mobile a = new Mobile();
Mobile b = a;
b.Name = "foo";
this means, that i will create a new mobile a then set another reference to mobile a, wich will be called b, so when i set b.Name = "foo" it will also modify the Name in a, right?
so what i want, is to create 2 identical Mobiles, but with different names
Mobile a = new Mobile();
Mobile b = new Mobile();
b = a;
b.Name = "foo";
this will not work, because when you set b = a it will also reference the memory pointer from a to b
so, how i create 2 identical mobiles but with different names, not one Mobile with two references?
Will i have to copy each attribute like Name, Str..one by one ?