2015-09-12 25 views
0
case "hello": 
case "hi" : 
// in the message box im trying to get multiple responces 
Console.writeLine("what's up"); 
break; 

我怎么会给它从“喜”和“你好”,我只是想知道是否有使用这个switch语句任何方式或如果我不得不写这一切多responces从字符串?我在这个有点小白的那一刻,感谢多个案件在C#中聊天机器人

+0

你不能在C#'switch'中“翻身”。我相信你可以使用'goto',但这通常不受欢迎。 – Tim

+0

啊好吧我想没有,我搜索了很多,没有运气 –

回答

1

你可以组合这两个选项是这样的:

switch (string) 
{ 
case "hello": case "hi: case "hi there":   
// Do Something 
break; 
case 4: case 5: case 6: 
// Do Something 
break; 
} 

古德勒克。