- Home /
String Scanning Switch Statement
Hello Everyone,
I have attempted to convert a certain if statement to a switch statement and have failed. How would I convert it? (Code below:)
if (myString.ToLower().Contains("good") && myString.ToLower().Contains("how are you")){
GUI.Label(Rect(550,200,Screen.width,Screen.height),"Good, thank you!");
conversationInit=true;
I think I'm getting stuck because I haven't seen a switch statement have 2 cases in one... Here's what I tried:
switch (myString.ToLower().Contains){
case "good" && "how are you":
GUI.Label(Rect(550,200,Screen.width,Screen.height),"Good, thank you!");
conversationInit=true;
break;
}
I appreciate your help. -Hyperion
Comment
Best Answer
Answer by tw1st3d · Oct 05, 2013 at 06:41 PM
This should work, don't see any reason it wouldn't.
switch(true)
{
case myString.ToLower().Contains("good") && myString.ToLower().Contains("how are you"):
GUI.Label(Rect(550,200,Screen.width,Screen.height),"Good, thank you!");
conversationInit = true;
break;
}
Your answer
Follow this Question
Related Questions
Using the StartsWith function in a Switch Case Statement 1 Answer
|| inside if statement not working. (noob) 3 Answers
|| conditional statement not working 1 Answer
Input using the same key twice 1 Answer
problem with child arrangement script 0 Answers