locked
Doesn't data type 'int' exist in C#.Net2013? RRS feed

  • Question

  • This is the code I wrote.

    public int  PreProc(ref string strLine)----> line 1)
            {

                string strDoublePl;

                string strDoubleSl;

                string strEScDoublePl;

                string strEscDoubleSl;

                    string strOldPattern;
     
                    string strNewPattern;

    While compiling, I got an error message saying " Expected class. delegate. enum interface, or struct."

    A red line was put under 'int' of line 1). It looks like saying that the data type 'int' is invalid in C#.

    I have used 'int' since year 2003.But Visual studio ultimate 2013 RC shows this error message.

    It sounds like saying the book I read in 2004, .NetFramework(written by Jeffrey Richter)is incorrect. Did I really make a  mistake? 

    Friday, October 18, 2013 1:00 AM

Answers

All replies

  • Again, you have somehow misplaced your code, it's probably outside of a class. You can't have global functions in C#.
    Friday, October 18, 2013 5:24 AM
  • That error message tends to indicate that you have too many closed parenthesis before your method declaration - so the compiler is looking for an outer class declaration - the method is being declared outside the class.

    ie:

    class foo { int Bar() { ... } } int Foobar() { // The above declaration will generate the
    // "Expected class. delegate. enum interface, or struct" error. }

    Cheers

    Mick

    Friday, October 18, 2013 5:29 AM