You must Sign In to post a response.
  • Category: .NET

    Error: Invalid token '=' in class, struct, or interface member declaration

    Why above error is coming after the compilation of this code. Thanks in advance.


    using System;
    class ReadonlyDemo
    readonly bool flag;
    static void Main()
  • #769541

    You have declare the flag variable as readonly and immediately you are trying to write a value to that variable. If you want to set the default value for that variable. Use the below code,

    readonly bool flag = true;

    V.M. Damodharan
    "Your talent will be worthless, when you have fear and tension."

  • Sign In to post your comments