考虑我在C#中执行方法'Method1'.一旦执行进入方法,我检查几个条件,如果它们中的任何一个是假的,那么应该停止执行Method1.我怎么能这样做,即可以在满足某些条件时执行方法.
但我的代码是这样的,
int Method1()
{
switch(exp)
{
case 1:
if(condition)
//do the following. **
else
//Stop executing the method.**
break;
case2:
...
}
}
Run Code Online (Sandbox Code Playgroud) c# ×1