Here's my code:
using System;
                    
public class Program
{
    
    private static string[] ar = new string[] {};
    
    public static void Main()
    {
        ar[0] = "hello";
        
        Console.WriteLine("Total array length: " + ar.Length);
        
    }
}
It show the error below when I run the above code:
Run-time exception (line 10): Index was outside the bounds of the array.
I thought that's how to define a dynamic array in C# but I must be missed something here.
 
     
     
    