Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
There are two kinds of documentation that are frequently written by developers. First, we have code comments, and second, we have help files. In this movie, I'll cover code comments, which explain the purpose of the current code and help make the code self-documenting. I am inside Visual Studio, and I have opened a solution called Comments, which contains two projects: a C# project and a Visual Basic project. I am going to spend the majority of my time commenting code in the C# project, but nearly everything I show you works exactly the same in Visual Basic, WPF, Silverlight, HTML--you name it.
Let's start by open this Book class. Here I have got a single-line comment. C# comments are started by using two slashes. I can also do multi-line comments. Let me open the Program.cs file. This is what a multi-line comment looks like. You start by putting the slash and the asterisks, and then you end the multi-line comment by using an asterisk and a slash. That comments out all the code between those. Another common use of comments is to take lines of code out there that you are not using anymore.
Let me show you how to do that part. I am going to go down to these two lines of code here and select them with my mouse. Now there is a keystroke that I like to use, which is Ctrl+K, Ctrl+U and Ctrl+K, Ctrl+C; U stands for Uncomment and C stands for Comment. So let's start by doing Ctrl+K. Visual Studio has this rather odd way of doing keystrokes. There are so many keystrokes in Visual Studio that sometimes they need to have multiple keystrokes. Now I have done a Ctrl+K. If you look on the lower left-hand corner of my screen, you will see that it says, "Ctrl+ K was pressed, waiting for second key of chord." And what they're saying is they are waiting for me to type Ctrl+C now. [00:01:44 .84] So let's do that Ctrl+C. Then that little tip on the bottom of the screen goes away, and the two lines that I had selected are now commented out.
This keystroke also works in Visual Basic. Let me show you. I'll go over to this VB file, Module1.vb, and then I will select a few lines of code over here. And then I will do the same keystroke: Ctrl+K, Ctrl+C. This time it comments out those three lines, but it uses the Visual Basic-specific comment character, which is the single quote or apostrophe. To uncomment, I do Ctrl+K, Ctrl+U, and if I am the kind of person that would rather use a button on the Toolbar, I can use either of these two buttons.
This button here is the Comment button, and this button is the Uncomment button. It's really a simple system. Comment systems are core features in every programming language I've ever worked in. It only takes a few minutes to show the parts of the comment system here in Visual Studio. For a more complex documentation story, be sure and watch the next movie in this chapter.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 102069 Viewers
61 Video lessons · 88784 Viewers
71 Video lessons · 72595 Viewers
56 Video lessons · 104237 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.