When changing a variable inside an object the similar variables in other objects do change to the same value
-
hello, I have an usual problem ( a least for me :) ), where I created multiple objects (say b1, b2, b3 ,b4 ) from the same class (b) inside another class (class a), the object is a1. The variable for class b such as "value" is changed for every object, for example a1.b1.value = 10; also a1.b2.value = 20; .. .. .. now when the value of 20 is entered in b2 the value in b1 is also changed to 20. Did anyone see this problem earlier? thanks
-
hello, I have an usual problem ( a least for me :) ), where I created multiple objects (say b1, b2, b3 ,b4 ) from the same class (b) inside another class (class a), the object is a1. The variable for class b such as "value" is changed for every object, for example a1.b1.value = 10; also a1.b2.value = 20; .. .. .. now when the value of 20 is entered in b2 the value in b1 is also changed to 20. Did anyone see this problem earlier? thanks
Hi, show actual code (in PRE tags!) and someone will explain to you what happened. :)
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
-
hello, I have an usual problem ( a least for me :) ), where I created multiple objects (say b1, b2, b3 ,b4 ) from the same class (b) inside another class (class a), the object is a1. The variable for class b such as "value" is changed for every object, for example a1.b1.value = 10; also a1.b2.value = 20; .. .. .. now when the value of 20 is entered in b2 the value in b1 is also changed to 20. Did anyone see this problem earlier? thanks
At a guess, it sounds like when you create your objects you are ending up with them all pointing to the same reference but without code it's hard to explain what is happening.
Scott Dorman
Microsoft® MVP - Visual C# | MCPD President - Tampa Bay IASA [Blog][Articles][Forum Guidelines]
Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
-
At a guess, it sounds like when you create your objects you are ending up with them all pointing to the same reference but without code it's hard to explain what is happening.
Scott Dorman
Microsoft® MVP - Visual C# | MCPD President - Tampa Bay IASA [Blog][Articles][Forum Guidelines]
Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
sounds like u did a code by using reference type.. so that it copied 20 to another object also..But we need to examine the code
sureshkumar.S