Console.WriteLine or ‘cw’ – Which one do you prefer ?

Few days back we have discussed about some of the hidden and very useful code snippet of visual studio, ‘propfull – for property and backing field’ and ‘forr’ code snippet for reverse ‘for’ loop.  Many of you have found them very useful and thanks for sharing the feedback. Today you will learn another interesting code snippet, calledcw’.

Well, it looks like very small or something silly, but to be honest it is not. While writing any code in the console application, to print any output, we used Console.Writeline, and you can guess the number of frequency of using it.  ‘cw’ is the code snippet for Console.WriteLine().

So, if you just type ‘cw’ and press TAB key twice, it will automatically  type the “Console.WriteLine()” and the cursor will be placed in between the braces so that you can continue your typing with out any interruption.

code snippet for console.writeline

code snippet for console.writeline completed

Again, this is not something new, it is there from the early days of Visual Studio.

Going forward, you can explore this kind of hidden snippet of  Visual Studio  just by navigating to “Code Snippets Manager” from “Tools –> Code Snippets Manager”. The following dialog window will help you to navigate through all the available snippet and the uses.

code snippet manager

Hope you will liked it.

Abhijit Jana

Abhijit runs the Daily .NET Tips. He started this site with a vision to have a single knowledge base of .NET tips and tricks and share post that can quickly help any developers . He is a Former Microsoft ASP.NET MVP, CodeProject MVP, Mentor, Speaker, Author, Technology Evangelist and presently working as a .NET Consultant. He blogs at http://abhijitjana.net , you can follow him @AbhijitJana . He is the author of book Kinect for Windows SDK Programming Guide.