Probably a simple syntax problem. This is an attempt at a console program that reads the length of a string that is received via user input. If the length is greater than 144, the user is notified that the string length is too long, otherwise the string inputted is just output to the console.
string input = Console.ReadLine();
(input.Length > 144) ? Console.WriteLine("The message is too long"); : Console.WriteLine(input);
Console.ReadLine();
Getting syntax errors in the present state on line 2. Am I missing parentheses?
Console.WriteLinereturns void. The ternary operator in C# is not a shortcut for anIf/elseEach side of the:in the operator must evaluate to some value and the result must be assigned or used somewhere.