What is the errors in the following C# program. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is the errors in the following C# program.

class Program { static Main(string[] args) { int x = 10 Console.WriteLine("{0}" + x); Console.ReadLine(); }

29th Jul 2020, 10:39 AM
Ruqiya
2 Answers
+ 1
Follow benjamin's advice, and then change the WriteLine call to Console.WriteLine("{0}", x);
29th Jul 2020, 11:20 AM
Ipang
+ 2
I think you need a void return type on the Main signature and a semi-colon at the end of the line where you declare the int. You also need a closing curly brace on the Main method. Also, the curly braces and quotes are not needed around the 0. If you did want to use interpolation then you'd need a dollar sign before the string, but it's not needed here.
29th Jul 2020, 10:43 AM
benjamin