i want to ask from user to enter how many entries he want to enter.kindly help me

when i declare local variable x and use it in array,the error is occure that use of un assign local variable.kindly help me
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
namespace ConsoleApplication11
{
     
    class Program
    {
       
        static void Main(string[] args)
        {
            int x;
            Console.Write("enter how many entries you want");
            Console.ReadLine();
            int[] randomNum = new int[x];//here problm is occuring
            Random RandomNumber = new Random();

            int counter = 0;
            for (int i = 0; i < x; i++)
            {
                randomNum[i] = RandomNumber.Next(1, x);
            }
the error is occure that use of un assign local variable
Where do you assign any value to x?
int x = 10; //declare and initialize the variable with some value.
without value the variable is termed as unassigned variable, a compile time error.
Topic archived. No new replies allowed.