Click here to Skip to main content
13,256,012 members (48,864 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

2.6K views
1 bookmarked
Posted 11 Feb 2011

Commenting/uncommenting segments easily in C#

, 12 Feb 2011
Rate this:
Please Sign up or sign in to 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();
#endif


And just change the 1 to 0 to switch between them...

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

SirTimothy
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

 
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171114.1 | Last Updated 13 Feb 2011
Article Copyright 2011 by SirTimothy
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid