Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

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.

like image 639
Nidhoggur Avatar asked Nov 28 '22 11:11

Nidhoggur


2 Answers

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

like image 102
stakx - no longer contributing Avatar answered Dec 18 '22 04:12

stakx - no longer contributing


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.

like image 32
Loren Pechtel Avatar answered Dec 18 '22 02:12

Loren Pechtel