+ 1
Why am I getting an error?
Why am I getting this error: ./Playground/file0.cs(14,25): error CS1002: ; expected https://code.sololearn.com/cJpSdgj226GT/?ref=app
3 Answers
+ 1
i'm not very good at c# but here is what i can find.
while statement use lowercase w. not While but while.
ReadLine doesnt take parameter. unlike python in here you need to print the message beforehand
last you cant declare same variable inside each case in switch. instead declare it before the switch statement
int result = 0
//switch here
+ 1
Rei
Thanks, youâre right on the 1st and 3rd point. After a few failed attempts, Iâve figured out/come to the conclusion that you canât, for some reason, reassign variables like you can in Python by redeclaring them.
Adding int result=0; before switch statement causes an error.
Also, doing
int result=0
int result=1
produces an error
So I think I meed to get rid of âintâ before âresultâ in the switch statement
+ 1
This is true. In c# a variable is declared once. Redeclaring a varable is not allowed.
You can assign another value to the variable as many times you like.
1) int result=3; //declare variable and initialze
2) result=4; //assign another value
3) result=5; //assign another value
4) Console.WriteLine(result);//display value