Comments
make the program more readable. Comments are used to document your code.
Suppose
you written thousand lines of program, without proper documentation, after some
time, for the owner of the application also, it is very difficult to figure out
what was written.
Comments solve this problem:
By
using comments, you can document your code at the time of writing program.
Comments don't affect your program execution. Comments simply document your
code.
C#
supports 3 types of comments
Single line comment :
Single
line comments starts with //
//
It is a single line comment
Multi Line comment
Multi
line comments are place in between /* */
/* I am a mulltiline comment */
XML Documentation
Comments
XML
Documentation comments are used to provide help to given class, function,
namespace etc.,
Program.cs
using System; class Program { static void Main(string[] args) { int marks; /* variable marks represents the marks obtained by a student */ marks = 70; Console.WriteLine("Marks : {0}", marks); //printing to console } }
Output
Marks
: 70
XML Documentation
Comments Example
Update
Program.cs like below.
Program.cs
using System; class Program { static void Main(string[] args) { IntresetCalculator calc; } } /// <summary> /// Class Calculates simple intrest /// </summary> class IntresetCalculator { }
When
you hover the mouse on ‘IntresetCalculator’, you can able to see the summary of
‘IntresetCalculator’ class.
No comments:
Post a Comment