How to comment C# code in Windows Application



Comment C# code

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.


Comment Code

  1. Single Line Comments
  2. Multi Lines Comments

Single Line Comments

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

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

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MyFirstProject
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{

}
private void button1_Click(object sender, EventArgs e)
{
// Single Line Comment

// C# Example Comment Code
}
}
}

In windows application 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, for uncomment the selected lines use Ctrl+E+U key.

Comment out the selected lines = Ctrl + E + C
Uncomment the selected lines = Ctrl + E + U

meeraacademy.com
Comment c# code in windows application.

Multi Lines Comments

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

Example of multi lines comments in c# windows application.

private void button1_Click(object sender, EventArgs e)
{
      /* Multi Lines Comment
         C# Example Comment Code */
}
meeraacademy.com
Comment c# code in windows application.

We hope that this c#.net tutorial helped you to understand about comment server side code in code behind page in windows application.


Next, c# windows application tutorial we will understand about how to create MessageBox.


 

Leave a Reply

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