It does not look like in your situation e.Result.Text
represents something that you can enumerate: you are checking the words that start the text, not the text in its entirety. In cases like this, you should not use a switch
, and go for a chain of if
-then
-else
s instead:
var text = e.Result.Text;
if (text.StartsWith("test")) {
writeConsolas("What do you want me to test?", me);
} else if (text.StartsWith("change username")) {
writeConsolas("What do you want to be called?", me);
} else if (text.StartsWith("exit")) {
writeConsolas("Do you wish me to exit?", me);
} else if (text.StartsWith("call me")) {
// Here you have the whole text. Chop off the "call me" part,
// using Substring(), and do whatever you need to do with the rest of it
} else
...