Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer String | Dealing with Data Types
C# Basics

bookString

A string is a sequence of characters. Strings are used for storing textual data.

main.cs

main.cs

copy
1234567891011121314
using System; namespace ConsoleApp { internal class Program { static void Main(string[] args) { string text = "Hello, World!"; Console.WriteLine(text); // Output: Hello, World! } } }

String data, or text, is always enclosed in double quotation marks (").

While arithmetic operations cannot be performed on strings, the plus (+) operator can be used to join two strings together. This process is known as string concatenation.

main.cs

main.cs

copy
123456789101112131415
using System; namespace ConsoleApp { internal class Program { static void Main(string[] args) { string partOne = "The first sentence. "; string partTwo = "The second sentence."; string combined = partOne + partTwo; Console.WriteLine(combined); // Output: The first sentence. The second sentence. } } }

We can use the new line character (\n) to represent a new line in string data.

Consider the following example:

main.cs

main.cs

copy
12345678910111213
using System; namespace ConsoleApp { internal class Program { static void Main(string[] args) { string text = "The first line.\nThe second line."; Console.WriteLine(text); } } }

When the \n character is encountered, the text automatically shifts to a new line. We can use multiple newline characters to skip multiple lines:

main.cs

main.cs

copy
12345678910111213
using System; namespace ConsoleApp { internal class Program { static void Main(string[] args) { string text = "The first line.\n\n\nThe second line.\nThe third line."; Console.WriteLine(text); } } }
question mark

What will be the output of the following code?

Select the correct answer

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 2. Hoofdstuk 6

Vraag AI

expand

Vraag AI

ChatGPT

Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.

Suggested prompts:

Can you explain more about string concatenation?

How does the newline character work in different programming languages?

Can you give more examples of using strings with special characters?

Awesome!

Completion rate improved to 1.59

bookString

Veeg om het menu te tonen

A string is a sequence of characters. Strings are used for storing textual data.

main.cs

main.cs

copy
1234567891011121314
using System; namespace ConsoleApp { internal class Program { static void Main(string[] args) { string text = "Hello, World!"; Console.WriteLine(text); // Output: Hello, World! } } }

String data, or text, is always enclosed in double quotation marks (").

While arithmetic operations cannot be performed on strings, the plus (+) operator can be used to join two strings together. This process is known as string concatenation.

main.cs

main.cs

copy
123456789101112131415
using System; namespace ConsoleApp { internal class Program { static void Main(string[] args) { string partOne = "The first sentence. "; string partTwo = "The second sentence."; string combined = partOne + partTwo; Console.WriteLine(combined); // Output: The first sentence. The second sentence. } } }

We can use the new line character (\n) to represent a new line in string data.

Consider the following example:

main.cs

main.cs

copy
12345678910111213
using System; namespace ConsoleApp { internal class Program { static void Main(string[] args) { string text = "The first line.\nThe second line."; Console.WriteLine(text); } } }

When the \n character is encountered, the text automatically shifts to a new line. We can use multiple newline characters to skip multiple lines:

main.cs

main.cs

copy
12345678910111213
using System; namespace ConsoleApp { internal class Program { static void Main(string[] args) { string text = "The first line.\n\n\nThe second line.\nThe third line."; Console.WriteLine(text); } } }
question mark

What will be the output of the following code?

Select the correct answer

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 2. Hoofdstuk 6
some-alt