简体   繁体   中英

Error CS1002: ; Expected — I have a semicolon. :(

Trying to create a new instance of the "MortgageData" object.

Professor said to use:

ClassName InstanceName = New ClassName(arg1, arg2, arg3, arg4);

I Used

MortgageData somethingsomething = New MortgageData(ID,principal,apr,term);

Keep getting Error CS1002: ; Expected with the class name after new underlined in red. I'm using visual studio 2008.

Not sure what to do.

For a start, write new instead of New . C# keywords are case-sensitive, and always in lower-case!

There's already an accepted, correct answer but I would like to add a general point here:

When you get an <x> expected error don't put too much faith in it. Something is wrong there but if you don't see an obvious case of omitting whatever it's asking for start looking for other things that could have confused the parser, especially unrecognized keywords.

new is different from New is different from NEW .

Use lower-case new .

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