adding + collapsing tree lists to large comment blocks - C# code in Visual Studio 2008
I am working on C# programming assignment for college. Part of my final for the class. The prof gave us a program, that works, but is very poorly written. We have to clean up t开发者_开发问答he code and add our own flair to it, but we have to do so with the original code, so that the prof can follow what we changed where.
Many of the methods have large chunks of redundant code that could be thrown into another method, once, then called on when needed.
I am commenting it all out, but it it easily takes up 80% of form.cs.
This leads me to my question:
Is there an easy way to add the plus sign drop downs so that I can collapse all the large comment blocks.
I am using MS Visual Studio 2008 Pro.
Thank you in advance for your help.
Use regions.
#region
// Block you want to expand/collapse
#endregion
You could add regions:
#region Commented out Method
//
//
//
#endregion
but I also think that if you use the
/* */
commenting notation, VS 2008 will automatically add the collapsible control to the sidebar of your code. I don't have VS 2008 currently to test that out but VS 2010 does that.
You could put all of this into region tags, but have you thought of using partial classes?
The form will probably already be a partial class, so you just need to create a new .cs file, and set the class definition the same as the one in form.cs
That way you can move all the redundant methods into the other file.
you could put your code in {}
{
// your comments
}
and it works like any other code blocks
but using region is more convincing, since it's a sign of "i know what i'm doing"
精彩评论