+ 3

Can someone help.

{ class Program { static void Main(string[] args) { string ans; ans = Console.ReadLine(); Console.WriteLine("I have a simple question..."); Console.WriteLine(""); Console.WriteLine("What is... idk, 1+1?"); Console.WriteLine("You said the answer is {0}", ans); if (ans == "2"); { Console.WriteLine("Correct! Good Job :D"); } if else { Console.WriteLine("How did you get that wrong?"); Console.WriteLine("Maybe you should go back to Primary School"); } } } } ./Playground/file0.cs(24,7): error CS1003: Syntax error, '(' expected ./Playground/file0.cs(24,7): error CS1525: Invalid expression term 'else' ./Playground/file0.cs(24,7): error CS1026: ) expected ./Playground/file0.cs(24,7): error CS8641: 'else' cannot start a statement. ./Playground/file0.cs(24,7): error CS1002: ; expected

4th Oct 2020, 9:06 AM
Kevin Xuli
Kevin Xuli - avatar
5 ответов
+ 1
codemonkey so i just write it in reverse order?
4th Oct 2020, 9:11 AM
Kevin Xuli
Kevin Xuli - avatar
+ 1
codemonkey it works now :D
4th Oct 2020, 9:20 AM
Kevin Xuli
Kevin Xuli - avatar
+ 1
Try now using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { string ans; ans = Console.ReadLine(); Console.WriteLine("I have a simple question..."); Console.WriteLine(""); Console.WriteLine("What is... idk, 1+1?"); Console.WriteLine("You said the answer is {0}", ans); if (ans == "2") { Console.WriteLine("Correct! Good Job :D"); } else { Console.WriteLine("How did you get that wrong?"); Console.WriteLine("Maybe you should go back to Primary School"); } }}}
4th Oct 2020, 10:31 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
0
codemonkey it just says ./Playground/file0.cs(23,5): error CS8641: 'else' cannot start a statement. ./Playground/file0.cs(23,5): error CS1003: Syntax error, '(' expected ./Playground/file0.cs(23,5): error CS1525: Invalid expression term 'else' ./Playground/file0.cs(23,5): error CS1026: ) expected ./Playground/file0.cs(23,5): error CS1002: ; expected ./Playground/file0.cs(24,11): error CS1003: Syntax error, '(' expected ./Playground/file0.cs(24,11): error CS1525: Invalid expression term '{' ./Playground/file0.cs(24,11): error CS1026: ) expected
4th Oct 2020, 9:15 AM
Kevin Xuli
Kevin Xuli - avatar
0
codemonkey thanks for the help
4th Oct 2020, 9:19 AM
Kevin Xuli
Kevin Xuli - avatar