Commenting/uncommenting segments easily in C#





5.00/5 (1 vote)
I use stuff like this quite often. Here's an extension, for switching quickly between two different code blocks://*doSomethingOneWay();/*/doSomethingAnotherWay();//*/As is, that will execute doSomethingOneWay(). To run doSomethingAnotherWay(), just take off the first...
I use stuff like this quite often. Here's an extension, for switching quickly between two different code blocks:
//* doSomethingOneWay(); /*/ doSomethingAnotherWay(); //*/As is, that will execute
doSomethingOneWay()
. To run doSomethingAnotherWay()
, just take off the first '/':
/* doSomethingOneWay(); /*/ doSomethingAnotherWay(); //*/Incredibly useful stuff for trying out two different ways to do something. Of course, if you use block comments anywhere in there, then it all gets messed up... I suppose the better way to do it would be to just use
#if
/#else
/#endif
but I like doing it with comments for some reason...
#if 1 doSomethingOneWay(); #else doSomethingAnotherWay(); #endifAnd just change the 1 to 0 to switch between them...