C#の特定のポイントから特定のコードをスキップするにはどうすればよいですか? if条件内で別のif条件を使用していて、その条件をスキップしたいとします。inner 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);
これは、ifが行っていることとまったく同じです。条件が満たされない場合、コードは実行されません。 – HimBromBeere
'if(discount> 100){return;}のようにinnerで' return'を使います。 } '。 – mmushtaq