如何跳过c#中特定点的特定代码? 假设在if条件中,我使用另一个if条件并且我想跳过该条件,而如果条件变为false,如何在内部跳过较低代码。那我该怎么做到呢? 这是我的方案跳过c#中特定点的特定代码?
if(true)
{
var discount = GetDicsount(price);
if(discount > 100)
{
//kill here and go away to from main if condition and skip do other work and move to GetType line directly
}
//Do Other Work
}
int type = GetType(20);
这就是如果这样做。如果条件不符合,代码将不会执行。 – HimBromBeere
如果像'if(discount> 100){return; }'。 – mmushtaq