如何编写switch语句 [英] how to write a switch statement
本文介绍了如何编写switch语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何以这种方式在C#中为az转换vb的switch语句" <
"
感谢解决方案没有直接翻译:C#
switch
cases
不能是值的范围.
您必须为每个单独的值提供一个理由.
switch(KeyAscii) { case '' '': case ''a'': ... case ''z'': strStringTyped = strStringTyped + KeyAscii.ToString(); break; }
可能最好使用string.IsLetter等.
how to convert a switch statement of vb in c# for a-z in this way"
Select Case KeyAscii
Case Asc(" ") To Asc("z")
strStringTyped = strStringTyped & _
Chr(KeyAscii)
"
thanks
解决方案
There is no direct translation: C#switch
cases
cannot be a range of values.
You would have to provide a case for each individual value.
switch(KeyAscii) { case '' '': case ''a'': ... case ''z'': strStringTyped = strStringTyped + KeyAscii.ToString(); break; }Probably, you would be better using string.IsLetter as so forth.
这篇关于如何编写switch语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文