How to write single-line comments in C#?

CsharpProgrammingServer Side Programming

If you want to add a comment that restricts itself to a single line, then use the single-line comments −

// variable
int i = 20;

The following is a sample C# program showing how to add single-line comments −

Example

 Live Demo

using System;

namespace Demo {
   class Program {
      static void Main(string[] args) {

         // display text
         Console.WriteLine("Hello World");
         Console.ReadKey();
      }
   }
}

Output

Hello World
raja
Published on 08-Aug-2018 13:27:06
Advertisements