pcbway




c# comments, c# comment, comment in c# , csharp commentHello everyone, hope you all are fine and having fun with your lives. Today’s tutorial is quite a quick type tutorial and it is about how to use C# Comments. Comments is an important part of any language. Comments are not directly part of the language but they indirectly affects a lot to any language. I have also shared a tutorial on How to use comments in c++ series. You should read that post as well because I have explained the basic concepts of comments.

You should also have a look at Introduction to C#  Windows Forms, which will give you the basics of C# language. You guys are also welcome to give us the feedback about this new C# Tutorial. If you have suggestions about it then also do let us know, so that we can make improvements. 🙂

How to use C# Comments ???

  • Comments are actually simple texts which are used to simply explain the coding.
  • Suppose you have some project and you simply close and the re open it after like a year.
  • Now when you read your own code then you will look like :O because you wont even understand your own code.
  • But if you have placed some check note for each commands then you can easily understand it.
  • These check notes are called C# comments.
  • Comments are started after these character // two forward slashes.
  • Now whatever you write in front of these two lines will be simply ignored by the compiler and they will remain as it is for your understanding.
  • So, let’s use the code which we have used in the C# String tutorial and we will add comments in it as shown in below figure:

c# comments, c# comment, comment in c# , csharp comment

  • Now you can see in the above figure that I have used these two slashes // and then I have written the text which is shown in green color in above figure.
  • So, I have given all the details in front of each lines.
  • Now it’s a way to write a C# Comments in a singe line, now let me show you how to add multiple line comments.
  • The multi line comments are enclose in these special characters /* Here’s your comment will come. */
  • This new styling of c# comments is shown in below figure:

c# comments, c# comment, comment in c# , csharp comment

  • Now in the above figure, you can see I have added the C# Comments above the code.
  • In this way you can add your copyrights for the code.

That’s all for C# comments. I hope you guys have understood the complete C# Comments. Till then take care and have fun. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

Post comment