C# Comments - c# - c# tutorial - c# net



C# Comment

Learn c# - c# tutorial - C# Comment - c# examples - c# programs

What are the types of comments in C# ?

  • The C# comments are statements that are not executed by the compiler.
  • The comments in C# programming can be used to provide explanation of the code, variable, method or class.
  • By the help of comments, you can hide the program code also.
  • A comment contains information that a programmer wants to add to describe the program.
  • Comments are marked with special characters that indicate that they should be ignored by the compiler.
  • They have no effect on the final software.
  • There are two types of comments in C#.
    • Single Line comment
    • Multi Line comment
 comment in C#

comment in C#

C# Single Line Comment

  • The simplest form of comment in C# is the single line comment.
  • The line is started with a double forward slash, (//).
  • Any text or code following the double slash is ignored during compilation.
  • Let's see an example of single line comment in C#.
using System;
public class CommentExample
    {
public static void Main(string[] args)
        {
int x = 10;//Here, x is a variable  
Console.WriteLine(x);
        } 
    }
click below button to copy the code. By - c# tutorial - team

C# examples - Output :

10
Related Tags: kurs c# , c# programmieren , tutorial c# visual studio , learn programming with c# , c# kurs online , the best way to learn c# , c# tutorial for complete beginners from scratch , tuto c# , manual c#

C# Multi Line Comment

  • The C# multi line comment is used to comment multiple lines of code.
  • It is surrounded by slash and asterisk (/* ..... */).
  • It is useful for commenting out large blocks of code.
  • Let's see an example of multi line comment in C#.
using System;	
public class CommentExample
    {
public static void Main(string[] args)
        {
            /* Let's declare and 
		print variable in C#. */ 
	int x=20;
Console.WriteLine(x);
        }
    }
click below button to copy the code. By - c# tutorial - team

C# examples - Output :

20


Related Searches to C# Comments