Course Home | What are Code Comments? | Code Example(s)
I would hope by this point in the course that you worked out how to add code comments in C#… I’m sure you have. For those that haven’t, it’s simply //.
//This is a code comment
That is the very basic, we also have a few more options available to us
/// <summary>
/// A summary of the class
/// </summary>
public class N_CodeComments
{
//So in VS if you type /// and press <enter> you'll get this
/// <summary>
/// We can write a summary of our method
/// </summary>
/// <param name="a">We can add more detail about paramter a</param>
/// <param name="b">We can add more detail about paramter b</param>
public void CodeCommentMethod(String a, int b)
{
//int c = 1; //If you press CMD or Ctrl+/ it will comment the line out/in
}
}
Using code comments is something that most developers frown upon. Their argument is that the code should be self-explanatory. Class, Methods and Variables should all be well named, so that’s immediately clear what they are for, or what they do. I can understand that stance. But you are new to C#, so add as many comments and you need, and keep adding them until you are comfortable enough not to.
Comments