Click here to Skip to main content
15,881,840 members
Articles / Programming Languages / Javascript
Alternative
Tip/Trick

Super-Easy Code Block Toggling

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
30 Aug 2011CPOL 7.8K   1
This nice trick extends into://*/block 1/*/block 2; // commented out/*/block 3;/*/block 4; // commented out//*/and removing the first slash gives inverted alternation:/*/block 1; // commented out/*/block 2;/*/block 3; // commented out/*/block...
This nice trick extends into:

C#
//*/
block 1
/*/
block 2; // commented out
/*/
block 3;
/*/
block 4; // commented out
//*/


and removing the first slash gives inverted alternation:

C#
/*/
block 1; // commented out
/*/
block 2;
/*/
block 3; // commented out
/*/
block 4;
//*/


This enables you to alternate between odd and even sequential blocks :). It will extend to infinite count of blocks! Even more curious but sometimes usefull nonetheless, alternation can be switched wherever you like:

C#
/*/
block 1; // commented out
/*/
block 2;
/*/
block 3; // commented out
/*/
block 4;
/*/
block 5; // commented out
/*/
block 6;
//*/


can be switched into:

C#
/*/
block 1; // commented out
/*/
block 2;
/*/
block 3; // commented out
/*/
block 4;
//*/
block 5;
/*/
block 6; // commented out
//*/

:D ILa

License

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


Written By
Engineer
Netherlands Netherlands
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralReason for my vote of 5 Superb my 5 Pin
Ashish Tyagi 406-Sep-11 19:12
Ashish Tyagi 406-Sep-11 19:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.