All,
Consider following piece of code:
string message = "abc;def;ghi";
string[] msgs = message.Split(';');
string temp = msg[2] ? msg[2] : "Failed";
Message variable is coming from the server and has different length. I need to parse it so that if the value does not exist, result should be “Failed”.
Is there an easy way to do that?
Right now this construct gives comppiler error: “Cannot convert string to bool”.
Thank you.
[EDIT]
I guess some people read this letter by letter. 😉
I need to check if an arbitrary element of the “msg” array exist, not just msg[2].
I can have something like:
string message = "abc;def";
str[] msg = message.Split( ';' );
string temp = msg[3] ? msg[3] : "Failed";
in the next message processing.
[/EDIT]
Perhaps you wanted:
Edit:
For checking any element, the same thing works: