---
title: "What is the difference between String and string in C#?"  
description: "What is the difference between String and string in C#?"  
author: "Steilla Mitchel"  
published: 2023-07-19  
updated: 2023-07-19  
canonical: https://www.mindstick.com/forum/159155/what-is-the-difference-between-string-and-string-in-c-sharp  
category: "c#"  
tags: ["c#", "string"]  
reading_time: 2 minutes  

---

# What is the difference between String and string in C#?

What is the [difference between String](https://www.mindstick.com/forum/85/difference-between-string-and-string-builder) and string in C#?

## Replies

### Reply by Aryan Kumar

Sure, I can help you with that.

In C#, **[String](https://www.mindstick.com/articles/1527/string-split-in-c-sharp)** and **string** are both keywords that represent a string variable. However, they are not the same.

**String** is a class in the .NET Framework's **System** namespace. It is a reference type that represents a sequence of characters.

**string** is an alias for the **System.String** class. This means that you can use either keyword to declare a string variable.

Here is an example of how to declare a string variable using both keywords:

```plaintext
// Using the String keyword
String myString = "Hello, world!";

// Using the string keyword
string yourString = "Hello, world!";
```

Both variables are of type **System.String** and they contain the same value.

The main [difference](https://www.mindstick.com/articles/157114/good-news-or-bad-news-and-the-difference-is) between **String** and **string** is that **String** is a keyword, while **string** is an alias. This means that **String** is reserved by the .NET Framework, while **string** is not.

In general, it is recommended to use the **string** keyword when declaring string variables. This is because the **string** keyword is more concise and easier to read.

Here is a summary of the key differences between **String** and **string** in C#:

| Feature | String | string |
| --- | --- | --- |
| Keyword | Yes | No |
| Class | System.String | System.String |
| Reference type | Yes | Yes |
| Represents a sequence of characters | Yes | Yes |
| Can be used to declare a string variable | Yes | Yes |
| Recommended to use | Yes | No |


---

Original Source: https://www.mindstick.com/forum/159155/what-is-the-difference-between-string-and-string-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
