Why can't I use break in a C# ternary expression?
I am trying to convert the if else clause to a ternary within a while loop, however it's not allowing me to have a break after the question mark, pointing an error at the break as an invalid expression. How would I go about turning this simple if else into a ternary like so. while (true) { Console.WriteLine("Enter 3 words seperated by spaces: "); var input = Console.ReadLine(); //input == "" ? break : ConvertToPascal(input); if (input == "") break; else ConvertToPascal(input); } } It isn't possible using the ternary operator, but you can simplify your code structure as follows: string input;