Studies show that good grammar leads to more promotions and higher salaries. Write with Grammarly

C# Error CS0443 – Syntax error, value expected

C# Compiler Error

CS0443 – Syntax error, value expected

Reason for the Error

You’ll get this error in your C# code when you try to reference an array without specifying the index for the array.

For example, let’s try to compile the below C# code snippet.

using System;
namespace DeveloperPublishNamespace
{
    class Program
    {      
        static void Main(string[] args)
        {
            int[] array1 = new int[10];
            var result = array1[];
            Console.WriteLine(result);
        }
    }
}

You’ll receive the error code CS0443 when you build the above C# code because you are referencing an array “array1” without specifying the array index.

Error CS0443 Syntax error; value expected DeveloperPublish C:\Users\Senthil\source\repos\ConsoleApp4\ConsoleApp4\Program.cs 9 Active

C# Error CS0443 – Syntax error, value expected

Solution

You can fix this error in your C# program ensuring that you specify the array index when referencing the array.

using System;
namespace DeveloperPublishNamespace
{
    class Program
    {      
        static void Main(string[] args)
        {
            int[] array1 = new int[10];
            var result = array1[0];
            Console.WriteLine(result);
        }
    }
}