Random variable in for each loop not working properly

Hello, I have a loop that runs through the rows of a table in which I generate a field with a random value - I use this instruction: new Random().Next(100000000,999999999).ToString.

The problem is that I have to include a delay of one second because otherwise the random is replicated in an average of ten rows until it changes.

With the delay it works fine but the processing time is more than an hour.

Any ideas?


How many rows do you have in the datatable and how do you specify the delay time?

There are about 4K rows and I put the delay just after the assign instructions

Do you need a number variable only?

If not, you can try Guid.NewGuid

Just tried your scenario seems to be working if I instantiate Random outisde foreach

random = new Random()

row("id")= random.Next(100000000,999999999).ToString.

Great vvaidya! Your solution is correct. It works when instantiating random outside foreach.
Thank you very much, you solve my problem!