Home About Lessons Blog On The Mic Contact Projects
Lessons BASIC · C#

C# Basics — String

7 min read · Emre Ulutabak
1
What is a string?

Name, city, message, email address... all of these are text.

In software, the data type used to store text is called string.

csharp
string isim = "Emre";
string mesaj = "Merhaba dünya";
💡
String values are written inside double quotes.
2
Why is it important?

Most programs work not only with numbers, but also with text. Usernames, passwords, descriptions, and error messages are often stored as strings.

3
String operations

You can perform many operations on strings, such as measuring length, changing letter case, and extracting parts.

csharp
string metin = "Merhaba";

Console.WriteLine(metin.Length);
Console.WriteLine(metin.ToUpper());
Console.WriteLine(metin.ToLower());
💡
Length returns the number of characters.
4
Concatenation and formatting

Sometimes you combine multiple strings. Other times, you insert variables into text. These tasks happen very often in daily programming.

csharp
string ad = "Emre";
int yas = 24;

string sonuc = $"Benim adım {ad}, yaşım {yas}.";
Console.WriteLine(sonuc);
💡
With the $ sign, you can use string interpolation to insert variables into text easily.
5
Golden rules

Strings may seem easy, but they are used in almost every project very frequently. Knowing the basics well is a big advantage.

💡
Do not treat text like numbers; strings have their own operations.
💡
ToUpper and ToLower are very useful for letter case conversions.
💡
Input coming from the user often starts as a string.
MINI QUIZ
Which of the following is correct?
String is only used for numbers
String is used to store text
Length deletes the text
String values are written inside curly braces