2014-02-16 36 views
-5

我有一個類這樣的(這是一個例子),我需要來自世界各地返回全班我需要它C#如何破解公共無效

Line1 :Public void test(bool start) 
Line2 :{ 
Line3 : if (start) //do something; 
Line4 : else // i use else for update with help other code and... forget it 
Line5 : { 
Line6 : if (xxX) 
Line7 :  if (sadasdas) 
Line8 :   if(sdaeqwr324f) 
Line9 :    if (Asdasdsa) 
Line10:     for (int a=0;a<6;a++) 
Line11:     { 
Line12:      if (c[a]==1321334) 
Line13:      { 
Line14:      t=c[1]; 
Line15: /* <<< i neeeed reset trace of test to first line of test Line16 :>>>*/ 
Line17:      } 
Line18:      } 
Line19:  there are about 400 lines codes like Up at under of this line } 
Line20:} 

我的目標是15行 - 如果我加一個return在示蹤跳轉到第17行 - 我需要示蹤跳轉到行2 對不起,我的英語不好(我搜索查找原因,解決它,但我不能找到anythings)

+0

它可能是你正在尋找的「返回」關鍵字?我不確定我是否理解這個問題 –

+0

爲什麼編輯我的問題?我沒有neeed它每個人都知道它 - 如果我在如果如果我想要從第三如果我打破目前如果和我的蹤跡去下一個 –

+1

這是可怕的。重構你的代碼。 – Blorgbeard

回答

3

爲了從一個函數使用return「破發」:

public void test(bool start) 
{ 
    if (start) //do something; 
    else // i use else for update with help other code and... forget it 
    { 
    //do somethings (it is loop) 
    pleas reset trace of test to first line of test 
    return; // This ends the method, and returns to the caller 
    } 
} 
+0

Retorn不是好方法,因爲我有很多,如果在它約400行代碼 –

+2

@ehsanwwe代碼的行數不應該是一個問題 - 只需將'return'放在您想要結束的位置執行。 – dasblinkenlight

+0

tnx評論:*我測試它,只是示蹤劑terurn最後如果例如3行在上,我跳過如果在上面,如果我想從第一行重置(我需要返回整個) –