C# Comments & It’s types

As we have discussed the concept of comments in a programming language you can also visit that page by clicking the link Comments in Python, Now today in this blog we shall discuss C# Comments.

C# Comments
C# Comments

C# Comments

C# Comments can be used to explain C# code and to make it more readable and it can be rememberable. It can also be used to prevent execution when testing alternative code.

Types of C# Comments

As we have discussed in our blog (Comments in Python) that there are generally main two types of comments

1-Single line comments

2-Multi Line comments

Single line comment

Single-line comments start with two forward slashes (//). Any text between // and the end of the line is ignored by C# compiler (will not be executed).

An example of single line comment is below

// This is a comment
Console.WriteLine("Hello World!");

Output with Single line comment

Hello World!
C# Comments

Multi-Line comments

Multi-line comments start with /* and end with */. Any text between /* and */ will be ignored by C# compiler.

An example of Multi Line comment is below

/* The code below will print the words Hello World
to the screen, and it is amazing */
Console.WriteLine("Hello World!"); 

Output Multi-Line comments

Hello World!

If I hope you got it and if you have any problem or query I am available you can contact me or comment below I will 100% surely reply to you. You can also be our permanent community member Free of Cost so you will stay updated just check the Yes, add me to your mailing list below the comments section or you can also register on our website to be part of the community Free of Cost as our motto is Binding Nation Through Education.

Medium Link: Follow me on Medium

Linkedin Link: Follow me on Linkedin

🤞 Don’t miss any latest posts!

Please subscribe by joining our community for free and stay updated!!!


Leave a Comment

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

Scroll to Top