Rambo Actionha
Rambo Actionha

Reputation: 115

invalid token in class declaration?

I have this code taken from Fo Dicom open source library , the code not compiling because the compiler complain that there are invalid tokens .

        /// <inheritdoc />
        public bool IsEOF => _stream.Position >= _stream.Length;

the error in this piece of code :

Error 101 Invalid token '>=' in class, struct, or interface member declaration c:\Users\user\Desktop\New folder\fo-dicom-development\DICOM\IO\FileByteSource.cs 93 47 DICOM.Desktop

why this happening ?

Upvotes: 0

Views: 405

Answers (1)

Alexei Levenkov
Alexei Levenkov

Reputation: 100547

You need c# 7 compiler to compile that type of member declaration.

Since you are using VS 2013 you get older version of c# compiler that does not know about this syntax and will fail to compile somewhere near the => as compiler always tries to male sense of as much code as possible. If you really interested why error reported on next operation grab the specification for c# version you actually end up using and figure out how it interprets public bool a => b ....

Upvotes: 1

Related Questions