How do I sort my code (by method name) in Visual Studio 2008?

前端 未结 5 2412
夕颜
夕颜 2021-02-19 20:22

Short of cutting and pasting, is there a way to sort the methods in my classes in Visual Studio 2008? I like orderly code.

5条回答
  •  一整个雨季
    2021-02-19 20:49

    If you are using Resharper, you can change the Type Members Layout template so that it orders your code however you like. See under Resharper>Options>Languages>C#>Type Members Layout. alt text http://www.jetbrains.com/resharper/features/screenshots/40/automatic_member_layout_full.png

    You can, for example, put methods with particular attributes first in your file... e.g. methods marked with NUnit's [Setup] and [TearDown] could come before methods marked with [Test] by placing a block like:

    
    
      
        
          
          
            
            
          
        
      
     
    

    before:

    
    
      
        
          
          
        
      
      
        
      
    
    

    and then have a catch-all for everything else:

    
    
      
        
      
    
    

    The template system is very powerful and should meet your needs.

提交回复
热议问题