在C#中退出Sub [英] Exit Sub in C#
本文介绍了在C#中退出Sub的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在vb.net中退出子或函数,我们可以说Exit Sub。我怎么能在C#中使用
摆脱void方法。我无法在任何地方找到记录。
谢谢,
T
解决方案
使用return。
示例:
void SomeMethod(){
if(condition)
返回;
其他
DoSmth()
}
"蒂娜" < TI ********** @ nospammeexcite.com>写道:
在vb.net中,为了摆脱子或函数,我们可以说Exit Sub。我怎样才能在C#中摆脱void方法。我无法在任何地方找到记录。
返回
- 巴里
-
http://barrkel.blogspot.com/#/ blockquote>在C#中使用'blockquote>你''return''。
实际上,在vb.net中不推荐使用Exit Sub。你也应该在那里使用返回
。
Jeff
-
Jeffrey Hornby
Hornby Consulting,Inc。
" Tina"写道:
在vb.net中,为了摆脱子或函数,我们可以说Exit Sub。我怎样才能在C#中摆脱void方法。我无法在任何地方找到记录。
谢谢,
In vb.net to get out of a sub or a function we can say Exit Sub. How can I
get out of a void method in C#. I can''t find that documented anywhere.
Thanks,
T
解决方案
use return.
Example:
void SomeMethod(){
if (condition)
return;
else
DoSmth()
}
"Tina" <ti**********@nospammeexcite.com> wrote:
In vb.net to get out of a sub or a function we can say Exit Sub. How can I
get out of a void method in C#. I can''t find that documented anywhere.
return
-- Barry
--
http://barrkel.blogspot.com/
in C# you use ''return''.
Actually, Exit Sub is deprecated in vb.net. You should be using return
there too.
Jeff
--
Jeffrey Hornby
Hornby Consulting, Inc.
"Tina" wrote:
In vb.net to get out of a sub or a function we can say Exit Sub. How can I
get out of a void method in C#. I can''t find that documented anywhere.
Thanks,
T
这篇关于在C#中退出Sub的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文