How to comment code in asp.net



How to comment C# code in asp.net

Comment code is important part of any kind of programming language.

Comment code is only visible at the part of programming side while run the program the comment code invisible at output side.

While complex programming we have more code at programmer side and many programmer can work on one project so we need to define the code logic with header comment code so other programmer can easily understood the code.


Two ways we can comment code in ASP.Net

  • Single Line Comments
  • Multi Lines Comments

Single Line Comments ASP.Net

In single line comments we can comment only single line using the comment expression using double slash “//”.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
       // Single line comment example

        // Comment code
    }
}

In above code we can see the how to comment single line using “//”.

In asp.net provide Comment out the selected lines icon to comment the line. We can comment line using shortcut key Select code for comments and press Ctrl+E, C.

How to comment code in asp.net c#.
How to comment code in asp.net c#.

Multi Lines Comments in ASP.Net

For multi lines comment write code between “/* ” and “*/”.

Example of multi lines comments in asp.net

protected void Button1_Click(object sender, EventArgs e)
    {
       /* Single line comment example

        Comment code */
    }

 

How to comment code in asp.net c#.
How to comment code in asp.net c#.

Related ASP.Net Topics :

Server side control in asp.net
Properties of server side control


Subscribe us

If you liked this asp.net post, then please subscribe to our YouTube Channel for more asp.net video tutorials.

We hope that this asp.net tutorial helped you to understand how to comment code in C#.


Next, asp.net tutorial we will understand about C# Data types.


1 thought on “How to comment code in asp.net

Leave a Reply

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