---
title: "What is C# and how many types of comments in this language?"  
description: "What is C# and how many types of comments in this language?"  
author: "Ravi Vishwakarma"  
published: 2021-11-29  
updated: 2023-06-06  
canonical: https://www.mindstick.com/interview/33852/what-is-c-sharp-and-how-many-types-of-comments-in-this-language  
category: "c#"  
tags: ["c#", ".net"]  
reading_time: 3 minutes  

---

# What is C# and how many types of comments in this language?

## What is C#

C# is an object-oriented, type-safe, and managed language that is compiled by .Net framework to generate Microsoft Intermediate Language.

**In C# have 3 types of comments.**

**\** **Single line comments**

```
//This is a single line comment
```

## Multiple line

```
/*This is a multiple line comment
We are in line 2
Last line of comment*/
```

## XML Comments

```
///<summary>Credit account with amount passed as parameter</summary>
 ///<example>After class initialisation, call this method:
 ///<code>
 ///var account = new Account(10, 2000);
 ///account.Credit(5000);
 ///</code>
 ///</example>
```

## Answers

### Answer by Aryan Kumar

C# is a general-purpose, object-oriented programming language developed by Microsoft. It is a compiled language, which means that it is converted into machine code before it is executed. C# is a member of the .NET Framework, which is a collection of software libraries and tools that developers can use to create applications.

C# has three types of comments:

- Single-line comments: These comments start with two forward slashes (//) and continue to the end of the line.
- Multi-line comments: These comments start with a forward slash and an asterisk (/*) and end with an asterisk and a forward slash (*/).
- Documentation comments: These comments start with three forward slashes (///) and are used to document C# code. Documentation comments can be used to generate help files and documentation for C# code.

Here is an example of a single-line comment:

C#

```plaintext
// This is a single-line comment.
```

Here is an example of a multi-line comment:

C#

```plaintext
/* This is a multi-line comment.
It can span multiple lines. */
```

Here is an example of a documentation comment:

C#

```plaintext
/// This is a documentation comment.
/// It can be used to generate help files and documentation for C# code.
public void MyMethod()
{
}
```

Comments are used to explain C# code and to make it more readable. They can also be used to prevent execution when testing alternative code.

Here are some of the benefits of using comments in C#:

- **Readability:** Comments can make C# code more readable by explaining what the code is doing. This can make it easier for developers to understand and maintain the code.
- **Testing:** Comments can be used to prevent execution when testing alternative code. This can help developers to test different code paths without having to worry about side effects.
- **Documentation:** Comments can be used to generate help files and documentation for C# code. This can help developers to learn how to use the code.

Comments are a valuable tool for any C# developer. They can be used to improve the readability, testability, and documentation of C# code.

### Answer by Ravi Vishwakarma

## What is C#

C# is an object-oriented, type-safe, and managed language that is compiled by .Net framework to generate Microsoft Intermediate Language.

**In C# have 3 types of comments.**

**\** **Single line comments**

```
//This is a single line comment
```

## Multiple line

```
/*This is a multiple line comment
We are in line 2
Last line of comment*/
```

## XML Comments

```
///<summary>Credit account with amount passed as parameter</summary>
 ///<example>After class initialisation, call this method:
 ///<code>
 ///var account = new Account(10, 2000);
 ///account.Credit(5000);
 ///</code>
 ///</example>
```


---

Original Source: https://www.mindstick.com/interview/33852/what-is-c-sharp-and-how-many-types-of-comments-in-this-language

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
