切换声明 [英] switch statement
问题描述
我知道你可以堆叠案例
案例1:
案例2:
但是你能拥有吗?在vb.net中的范围确实类似于(1到6)类型的东西,或者
< n或n等。
Just Me写道:
我知道你可以堆叠案例
案例1:
案例2:
但是你可以拥有范围,因为在vb.net中确实喜欢(1到6)类型的
的东西,或者< n或n等等。
不,你不能。因此,在这些情况下,你要么必须在彼此之上堆叠案例
,要么使用if / else语句的christmastree :)
FB
-
------------------------------- -----------------------------------------
铅LLBLGen Pro的开发人员,.NET的高效O / R映射器
LLBLGen Pro网站: http://www.llblgen.com
我的.NET博客: http://weblogs.asp.net/fbouma
Microsoft MVP(C#)
-------- -------------------------------------------------- --------------
" Just Me" < news.microsoft.com写信息
news:ug ************** @ TK2MSFTNGP06.phx.gbl ...
>我知道你可以堆叠案例
案例1:
案例2:
但你能否拥有范围,因为在vb.net中确实喜欢(1到6)类型的东西,
或< n或n等等。
不,不在C#中。您将不得不堆叠一些if ... else if ...阻止
这样做。
Just Me写道:
也许是只是我,但这似乎有点限制。 vb.net选择/案例
案例在这种特殊情况下比c#更灵活(没有双关语
意图)。
一般来说,语言不能很好地获得所有可能的
功能(PL / I,Ada等等。 )。
所以功能优先。这个最终低于C#的
行。
我没有遇到任何问题。我认为这是相对罕见的
想要这样做*和*代码不需要进行一些清理。
Arne
I know you can stack case(s)
case 1:
case 2:
but can you have ranges as in vb.net does like ( 1 to 6 ) type of thing, or
<n or n etc.
Just Me wrote:
I know you can stack case(s)
case 1:
case 2:
but can you have ranges as in vb.net does like ( 1 to 6 ) type of
thing, or <n or n etc.No, you can''t. So in those situations, you either have to stack cases
on top of eachother or use a christmastree of if/else statements :)
FB
--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
"Just Me" <news.microsoft.comwrote in message
news:ug**************@TK2MSFTNGP06.phx.gbl...>I know you can stack case(s)
case 1:
case 2:
but can you have ranges as in vb.net does like ( 1 to 6 ) type of thing,
or <n or n etc.No, not in C#. You will have to stack some "if... else if..." blocks to
do that.
Just Me wrote:Maybe its just me, but this seems a bit limiting really. vb.net select/case
case(s) are more flexible than c# in this particular case ( no pun
intended ).In general it is not good for a language to get all possible
features (PL/I, Ada etc. show how that goes).
So features are prioritized. And this one ended up below the
line for C#.
I don''t have a problem with that. I think it is relative rare
to want to do that *and* the code are in need not for some cleanup.
Arne
这篇关于切换声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!