C# Beginner question | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

C# Beginner question

Hello, can someone please help me with this. I'm getting a compiling error. I'm running it in Visual Studio. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp9 { class Program { static void Main(string[] args) { double height = 4.0; if(height >= 5.0) { Console.WriteLine("you are tall enough"); else Console.WriteLine("you are too short!"); }

29th Jul 2018, 4:36 PM
Alex
Alex - avatar
2 Answers
+ 2
The problem is that the else statement is inside the if block, when you put it outside and close off the class and namespace curly brackets the application should compile flawlessly. Next time put your code in a C# code on Sololearn and link it to make it easier for us to help you.
29th Jul 2018, 4:46 PM
TurtleShell
TurtleShell - avatar
+ 2
Error on the writing of blocks. if(height >= 5.0) { Console.WriteLine("you are tall enough"); } else { Console.WriteLine("you are too short!"); }
30th Jul 2018, 3:08 PM
Tojo Natolotra RANAIVOZANANY
Tojo Natolotra RANAIVOZANANY - avatar