- Where Developers Learn, Share, & Build Careers
I have a strange problem with some of my code; I have made a list of some items; When trying to fill this list with new items, if I use F5 , then all the members of the list will be created like each other! But when I try to debug this problem with F11 , then members of the list will be separated from each other (which is correct). I am using a loop to generate all the members of the list, and in each iteration of the loop, I add the first class object using the I define the list as follows: The problem is that new random () method in each iteration of the loop Due to the use of this, the right way to do this is to use it for example once out of the loop, and Then only use new and then add it to the list I am
list & lt; MyClass & gt; Find out why F5 does not fill the list correctly I tried to repeat the same problem in other classes which contained only strings and integer members, but it works properly.
rndNumber = new random ()
rndNumber.Next () in the loop; More information about the solution can be found in the following link:
Comments
Post a Comment