2011-05-17 102 views
0

的Visual Basic 2010會自動更改我的代碼縮進從這個::如何防止visual studio搞亂我的代碼的身份?

public void fetchWebserviceCounters() { 
    csv = new StringBuilder(); 
    try { 
     Category = new PerformanceCounterCategory("Web Service"); 
     foreach (String instance in Category.GetInstanceNames()) { 
      counters = Category.GetCounters(instance); 
      foreach (PerformanceCounter counter in counters) { 
       if (counter.CounterName == "Total Bytes Sent" | counter.CounterName == "Total Bytes Recieved") { 
       csv.Append(counter.CounterName + ","); 
       csv.Append(counter.NextValue().ToString() + ", "); 
       } 
      } 
     } 
    } 
    catch (Exception e) { 
      Console.WriteLine(e.Message); 
    } 
    Console.Write(csv.ToString()); 

}

這個

public void fetchWebserviceCounters() 
    { 
     csv = new StringBuilder(); 
     try 
     { 
      Category = new PerformanceCounterCategory("Web Service"); 
      foreach (String instance in Category.GetInstanceNames()) 
      { 
       counters = Category.GetCounters(instance); 
       foreach (PerformanceCounter counter in counters) 
       { 
        if (counter.CounterName == "Total Bytes Sent" | counter.CounterName == "Total Bytes Recieved") 
        { 
         csv.Append(counter.CounterName + ","); 
         csv.Append(counter.NextValue().ToString() + ", "); 
        } 
       } 
      } 
     } 
     catch (Exception e) 
     { 
      Console.WriteLine(e.Message); 
     } 
     Console.Write(csv.ToString()); 
    } 

如何防止Visual Basic中,從這樣做是爲了我的代碼

回答

3

如果您將C#傳遞給Visual Basic編輯器,那麼期望將其搞亂。

VS中有很多文本格式選項:工具|選項|文本編輯器|語言|格式化。

這些程度取決於語言,並且包括有關代碼何時自動重新格式化的選項。

+0

其他:您將需要的東西在工具|選項|文本編輯器|語言|格式化|新行|大括號的新行選項。 – PVitt 2011-05-17 08:25:41

相關問題