Using C# Ternary Operator -


probably simple syntax problem. attempt @ console program reads length of string received via user input. if length greater 144, user notified string length long, otherwise string inputted output console.

string input = console.readline(); (input.length > 144) ? console.writeline("the message long"); : console.writeline(input); console.readline(); 

getting syntax errors in present state on line 2. missing parentheses?

try:

console.writeline((input.length > 144) ? "the message long" : input); 

you need use return value of operator, or receive compile-time error only assignment, call, increment, decrement, , new object expressions can used statement.

none of these other answers compile, i'm not sure getting at.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -