简体   繁体   中英

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 ?

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 ... .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM