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

C# Error CS0204 – Only 65534 locals, including those generated by the compiler, are allowed

C# Compiler Error

CS0204 – Only 65534 locals, including those generated by the compiler, are allowed

Reason for the Error

You will receive this error when you have declared more than 65534 variables scoped locally in your C# program. You have exceeded the limit of 65534 local variables in a method.

This program will result with the error code CS0204 because the Main method has 66712 variables declared which exceeds the limit.

Error CS0204 Only 65534 locals, including those generated by the compiler, are allowed ConsoleApp3 C:\Users\SenthilBalu\source\repos\ConsoleApp3\ConsoleApp3\Program.cs 13 Active

C# Error CS0204 - Only 65534 locals, including those generated by the compiler, are allowed

Solution

To fix the error code CS0204, ensure that the maximum number of variables declared with-in a function doesnot exceed the limit defined by C# compiler.