如何跳過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