What will be the output of the following C# code snippet? [code] static void Main(string[] args) { StringBuilder sb = new StringBuilder("

What will be the output of the following C# code snippet?
Code:
 static void Main(string[] args)
 {
     StringBuilder sb = new StringBuilder("hello world");
     sb.Insert(6, "good");
     Console.WriteLine(sb);
     Console.ReadLine();
 }
A. hello 6world
B. hello good world
C. hello goodworld
D. hello good world
 
Answer: c
Explanation: The insert() method inserts one string into another. It is overloaded to accept values of all simple types, plus String and Objects. String is inserted into invoking object at specified position. “Good ” is inserted in “Hello World” index 6 giving “Hello Good World”.
 

Tìm kiếm

Back
Top