Is this really my fault? RRS feed

  • Question

  • Compiling following code, I was faced to an error message, saying "Invalid token '=' in class, struct, or interface membrt declaration."with red line under line 3).

    In my opinion, It is a  part of basic grammer in C#.Net to use '=' in order to define a variable. I used visual studio ultimate 2013 RC.

    string[] strArrToReturn; line 1)

                char[] charArrDelimTab;  line 2)

                charArrDelimTab = new char []{'\t'}; line 3)

                strArrToReturn = strText.Split(charArrDelimTab);

                return strArrToReturn;


    Thursday, October 17, 2013 4:42 AM


All replies

  • You probably placed this code outside a function. Make sure you don't have misplaced braces ({, }) or something like that.
    Thursday, October 17, 2013 6:15 AM
  • Thank you for the kind comment. I placed this code inside a public member function of a class.I can't understand why this problem happened. Anyway, I will try again tomorrow morning. 
    Thursday, October 17, 2013 11:32 AM
  • Hi Ida89,

    C# is an Object-Oriented language, all members must be placed in the class body. Otherwise, the compiler will return an error and does not compile. See for more information about Object-Oriented.

    Best Regards,

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, October 22, 2013 3:19 AM