0
    static void randomize(Pora[] arr,int n, int seed)
    {
        arr = new Pora[n];
        Random rand = new Random(seed);
        for (int i = 0; i < n; i++)
        {
            arr[i].integer = rand.Next();
            arr[i].doubl = rand.NextDouble();
        }
    }

I try to get random values for my pairs of int and double but I seem to get an error.

Haidrex
  • 15
  • 5
  • What is pora? edit your code to add this missing class – aloisdg Mar 30 '20 at 15:03
  • 4
    Does this answer your question? [What is a NullReferenceException, and how do I fix it?](https://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – pmcoltrane Mar 30 '20 at 15:03
  • Creating an array that can store n items of type Pora doesn't mean that you have n items of type Pora already defined and ready to be used. You need to create them one by one and store them in the appropriate index into the array. Then you can use them – Steve Mar 30 '20 at 15:03
  • The first line in your `for` loop should be `arr[i] = new Pora();`. You have created and array, but it is empty. – Chris Dunaway Mar 30 '20 at 21:55

0 Answers0