0

C# syntax

My (very basic) code is this: int number = Convert.ToInt32(Console.Readline()); if (number%3==0) Console.WriteLine(*); else Console.WriteLine(number++); The only error I get is: Invalid expression term ')' What am I missing? Thanks in advance!

24th Apr 2022, 2:27 PM
Micah Whitcomb
4 Respuestas
+ 3
Kamil Hamid No need of curly braces for single line statement. Micah Whitcomb Without double quotes a string will be considered as a variable but * cannot be use as a variable so there is invalid expression. So * should be inside double quotes.
24th Apr 2022, 2:48 PM
A͢J
A͢J - avatar
+ 1
There are 2 mistakes 1st one ReadLine L should be capital. 2nd same like A͢J said.
24th Apr 2022, 3:05 PM
SoloProg
SoloProg - avatar
0
int number = Convert.ToInt32(Console.ReadLine()); if (number%3==0) Console.WriteLine("*"); else Console.WriteLine(number++);
24th Apr 2022, 2:34 PM
SoloProg
SoloProg - avatar
0
You forgot to put curly braces {} around the code of the if and else statements, and the asterisk should be in "" as a string. That should fix it
24th Apr 2022, 2:37 PM
Kamil Hamid
Kamil Hamid - avatar