Complete the code to get the length of the string.
string text = "hello"; int length = text.[1];
The Length property returns the number of characters in the string.
Complete the code to get the first character of the string.
string word = "apple"; char firstChar = word[1]0;
Strings can be accessed like arrays using square brackets [] with the index inside.
Fix the error in the code to convert the string to uppercase.
string name = "john"; string upperName = name.[1]();
The correct method to convert a string to uppercase in C# is ToUpper().
Fill both blanks to create a substring from index 2 with length 3.
string text = "example"; string sub = text.[1]([2], 3);
The Substring method extracts a part of the string starting at the given index. Here, index 2 and length 3 are used.
Fill all three blanks to check if the string contains 'cat' and print a message.
string animal = "concatenate"; if (animal.[1]("[2]")) { Console.[3]("Found cat!"); }
The Contains method checks if a substring exists inside a string. WriteLine prints the message to the console.
