简单的开关声明问题 [英] simple switch statement question
本文介绍了简单的开关声明问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在vb6中你可以这样做:
选择案例值
案例1,2
' '做点什么
结束案例
你怎么用c#做这个?
谢谢。
in vb6 you can do this:
select case value
case 1, 2
''do something
end case
how do you do this in c#?
thanks.
推荐答案
你可以这样做:
开关(鱼)
{
case onefish:
case twofish:
case redfish:
DoSomething();
break;
case bluefish:
DoSomethingElse();
休息;
}
-
Bob Powell [MVP]
Visual C#,System.Drawing
所有你想知道的关于ListView自定义绘图在Well Formed中。
http://www.bobpowell。 net / currentissue.htm
用GDI + FAQ回答那些GDI +问题
http:// ww w.bobpowell.net/gdiplus_faq.htm
GDI +常见问题解答: http ://www.bobpowell.net/faqfeed.xml
Windows窗体提示和技巧: http://www.bobpowell.net/tipstricks.xml
鲍勃的博客: http://royo.is-a-geek.com/siteFeeder...aspx ?FeedId = 41
* RSS * RSS * RSS * RSS * RSS * RSS * RSS * RSS * RSS * RSS * RSS * RSS * R SS *
" suzy" <苏** @ spam.com>在消息中写道
新闻:DE **************** @ doctor.cableinet.net ...
You can do:
switch(fish)
{
case onefish:
case twofish:
case redfish:
DoSomething();
break;
case bluefish:
DoSomethingElse();
break;
}
--
Bob Powell [MVP]
Visual C#, System.Drawing
All you ever wanted to know about ListView custom drawing is in Well Formed.
http://www.bobpowell.net/currentissue.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm
*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*R SS*
The GDI+ FAQ: http://www.bobpowell.net/faqfeed.xml
Windows Forms Tips and Tricks: http://www.bobpowell.net/tipstricks.xml
Bob''s Blog: http://royo.is-a-geek.com/siteFeeder...aspx?FeedId=41
*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*R SS*
"suzy" <su**@spam.com> wrote in message
news:DE****************@doctor.cableinet.net...
在vb6中你可以做到这一点:
选择案例值
案例1,2
''做点什么
结束案件
你怎么用c#做这个?
谢谢。
in vb6 you can do this:
select case value
case 1, 2
''do something
end case
how do you do this in c#?
thanks.
我知道,但是什么如果我想为鱼的几个价值运行相同的代码?
Bob Powell [MVP]" < bob@_spamkiller_bobpowell.net>在留言中写道
news:OH ************** @ TK2MSFTNGP09.phx.gbl ...
i know that, but what if i want to run the same bit of code for several
values of fish?
"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:OH**************@TK2MSFTNGP09.phx.gbl...
你可以这样做:
开关(鱼)
{/>案例一条鱼:
案例twofish:
案例redfish:
DoSomething();
break ;
案例鲑鱼:
DoSomethingElse();
休息;
}
- 鲍勃鲍威尔[MVP]
Visual C#,System.Drawing
所有你想知道的ListView自定义绘图都在
Formed中。 http://www.bobpowell.net/currentissue.htm >
使用GDI +常见问题回答这些GDI +问题
http:/ /www.bobpowell.net/gdiplus_faq.htm
* RSS * RSS * RSS * RSS * RSS * RSS * RSS * RSS * RSS * RSS * RSS * RSS * R SS *
GDI +常见问题解答: http://www.bobpowell。 net / faqfeed.xml
Windows窗体提示和技巧: http ://www.bobpowell.net/tipstricks.xml
鲍勃的博客: http://royo.is-a-geek.com/siteFeeder...aspx?FeedId=41
> * RSS * RSS * RSS * RSS * RSS * RSS * RSS * RSS * RSS * RSS * RSS * RSS * R SS *
" suzy" <苏** @ spam.com>在消息中写道
新闻:DE **************** @ doctor.cableinet.net ...
You can do:
switch(fish)
{
case onefish:
case twofish:
case redfish:
DoSomething();
break;
case bluefish:
DoSomethingElse();
break;
}
--
Bob Powell [MVP]
Visual C#, System.Drawing
All you ever wanted to know about ListView custom drawing is in Well Formed. http://www.bobpowell.net/currentissue.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm
*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*R SS*
The GDI+ FAQ: http://www.bobpowell.net/faqfeed.xml
Windows Forms Tips and Tricks: http://www.bobpowell.net/tipstricks.xml
Bob''s Blog: http://royo.is-a-geek.com/siteFeeder...aspx?FeedId=41
*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*R SS*
"suzy" <su**@spam.com> wrote in message
news:DE****************@doctor.cableinet.net...
在vb6中你可以这样做:
选择案例值
案例1,2
''做点什么
结束案
如何你是用c#做的吗?
谢谢。
in vb6 you can do this:
select case value
case 1, 2
''do something
end case
how do you do this in c#?
thanks.
你需要每个案例休息一下。
case onefish:
休息;
案例twofish:
休息;
case redfish:
...
伯尔尼
" Bob Powell [MVP]" < bob@_spamkiller_bobpowell.net>在留言中写道
news:OH ************** @ TK2MSFTNGP09.phx.gbl ...
You need a break per case.
case onefish:
break;
case twofish:
break;
case redfish:
...
Bern
"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:OH**************@TK2MSFTNGP09.phx.gbl...
你可以这样做:
开关(鱼)
{/>案例一条鱼:
案例twofish:
案例redfish:
DoSomething();
break ;
案例鲑鱼:
DoSomethingElse();
休息;
}
- 鲍勃鲍威尔[MVP]
Visual C#,System.Drawing
所有你想知道的ListView自定义绘图都在
Formed中。 http://www.bobpowell.net/currentissue.htm >
使用GDI +常见问题回答这些GDI +问题
http:/ /www.bobpowell.net/gdiplus_faq.htm
* RSS * RSS * RSS * RSS * RSS * RSS * RSS * RSS * RSS * RSS * RSS * RSS * R SS *
GDI +常见问题解答: http://www.bobpowell。 net / faqfeed.xml
Windows窗体提示和技巧: http ://www.bobpowell.net/tipstricks.xml
鲍勃的博客: http://royo.is-a-geek.com/siteFeeder...aspx?FeedId=41
> * RSS * RSS * RSS * RSS * RSS * RSS * RSS * RSS * RSS * RSS * RSS * RSS * R SS *
" suzy" <苏** @ spam.com>在消息中写道
新闻:DE **************** @ doctor.cableinet.net ...
You can do:
switch(fish)
{
case onefish:
case twofish:
case redfish:
DoSomething();
break;
case bluefish:
DoSomethingElse();
break;
}
--
Bob Powell [MVP]
Visual C#, System.Drawing
All you ever wanted to know about ListView custom drawing is in Well Formed. http://www.bobpowell.net/currentissue.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm
*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*R SS*
The GDI+ FAQ: http://www.bobpowell.net/faqfeed.xml
Windows Forms Tips and Tricks: http://www.bobpowell.net/tipstricks.xml
Bob''s Blog: http://royo.is-a-geek.com/siteFeeder...aspx?FeedId=41
*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*R SS*
"suzy" <su**@spam.com> wrote in message
news:DE****************@doctor.cableinet.net...
在vb6中你可以这样做:
选择案例值
案例1,2
''做点什么
结束案
如何你是用c#做的吗?
谢谢。
in vb6 you can do this:
select case value
case 1, 2
''do something
end case
how do you do this in c#?
thanks.
这篇关于简单的开关声明问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文