简体   繁体   English

错误 CS1002: ; 预期 - 我有一个分号。 :(

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

Trying to create a new instance of the "MortgageData" object.尝试创建“MortgageData”对象的新实例。

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: ;不断收到错误 CS1002: ; Expected with the class name after new underlined in red.预计在新的红色下划线之后的类名。 I'm using visual studio 2008.我正在使用 Visual Studio 2008。

Not sure what to do.不知道该怎么办。

For a start, write new instead of New .首先,编写new而不是New C# keywords are case-sensitive, and always in lower-case! C# 关键字区分大小写,并且总是小写!

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.当您收到 <x> 预期错误时,不要太相信它。 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 . new不同于New不同于NEW

Use lower-case new .使用小写的new

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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