Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Using uninititalized array C#

I am using Visual Studio, .NET 8.0.

There is my code:

using System;
using System.Globalization;

namespace Learn
{
    class Program
    {
        public static void Main(string[] args)
        {
           int c;
           int[] arr;
           c = int.Parse(Console.ReadLine());

           for (int i = 0; i <= c - 1; i++)
           {
               arr[i] = int.Parse(Console.ReadLine()); 
           }
       }
   };
}

I tried to input this:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

3
1
1
1

I get an error CS0165

How to fix that?

>Solution :

you can use List instead of array

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading