College 9 Flashcards

1
Q

Hoe gebruik je de Length-property in een String object in C#?

A

De Length-property geeft de lengte van de string terug (in aantal karakters).

string s = “Hallo”;
Console.WriteLine(s.Length); // Output: 5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Hoe werkt string-concatenatie in C#?

A

Strings kunnen worden samengevoegd met +.

Alternatief: String-interpolatie met $.

string s1 = “Hallo”;
string s2 = “Wereld”;
Console.WriteLine(s1 + “ “ + s2); // Output: Hallo Wereld
Console.WriteLine($”{s1} {s2}”); // Output: Hallo Wereld

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Wat is een tweedimensionale array in C#, en hoe initialiseer je deze?

A

Een tweedimensionale array heeft rijen en kolommen.

int[,] matrix = new int[3, 3];
matrix[0, 1] = 5; // Tweede element van de eerste rij
Console.WriteLine(matrix[0, 1]); // Output: 5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Wat doet de Substring-methode van een string in C#?

A

Substring haalt een deelstring uit een string.

string s = “Programmeren”;
string deel = s.Substring(0, 5); // “Progr”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly