Complete the code to concatenate two strings and print the result.
string greeting = "Hello" + [1]; Console.WriteLine(greeting);
In C#, strings must be enclosed in double quotes. Adding " World" concatenates the two strings correctly.
Complete the code to concatenate a string and an integer by converting the integer to a string.
int number = 5; string message = "Number: " + [1]; Console.WriteLine(message);
To concatenate an integer with a string, convert the integer to a string using ToString().
Fix the error in the code to concatenate strings using the String.Concat method.
string part1 = "Good"; string part2 = "Morning"; string result = String.Concat(part1, [1]); Console.WriteLine(result);
The String.Concat method concatenates string arguments. Use the variable part2 directly without quotes.
Fill both blanks to create a string interpolation that includes a variable and an expression.
int apples = 3; string message = $"I have [1] apples and [2] more."; Console.WriteLine(message);
In string interpolation, expressions must be inside curly braces. Use {apples} and {apples + 2} inside the string.
Fill all three blanks to build a concatenated string with a variable, a method call, and a literal.
string name = "Anna"; string greeting = "Hello, " + [1] + ", you have " + [2] + [3]; Console.WriteLine(greeting);
The code concatenates the variable name, the uppercase version of name, and a string literal with a period. Use name, name.ToUpper(), and " apples.".