About Random in for loop

List<int> intnum = new List<int>();

    for(int i = 0;i < 10;i++)
    {
      Random rnd = new Random();
      int num = rnd.Next(0, 2);
      if(num == 0)
      {
        intnum.Add(num);
      }
    }
    A = intnum;

In upon code, I can’t get random numbers, why?
I get all the same numbers!

Pull the Random declaration outside of your loop.

var rnd = new Random();
for (var i = 0; i < 10; i++)
  RhinoApp.WriteLine("{0}", rnd.Next(0, 2));

Thank you! It works!