Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

What will be the output of the following C# code?
static void Main(string[] args)
{
string Name = “He is playing in a ground.”;
char[] characters = Name.ToCharArray();
StringBuilder sb = new StringBuilder();
for (int i = Name.Length – 1; i >= 0; –i)
{
sb.Append(characters[i]);
}
Console.Write(sb.ToString());
Console.ReadLine();
}

What will be the output of the following C# code?
static void Main(string[] args)
{
string Name = “He is playing in a ground.”;
char[] characters = Name.ToCharArray();
StringBuilder sb = new StringBuilder();
for (int i = Name.Length – 1; i >= 0; –i)
{
sb.Append(characters[i]);
}
Console.Write(sb.ToString());
Console.ReadLine();
}
a) He is playing in a grou
b) .ground a in playing is He
c) .dnuorg a ni gniyalp si eH
d) He playing a

Answer: c
Explanation: Reversal of array of strings character by character.
Output:
.dnuorg a ni gniyalp si eH

Join The Discussion