harish reddy

harish reddy

  • NA
  • 162
  • 33.8k

String buider . Append

Mar 28 2018 11:32 PM
I am not getting the output and i am getting the arugument out of range exception for the same. 
 
//Write a program that reads a string from the console (20 characters maximum) and if shorter complements it right with "*" to 20 characters.
StringBuilder first = new StringBuilder(50);
string input = Console.ReadLine();
if (input.Length<=20)
{
first.Append(input);
Console.WriteLine(first);
first.Append("x", (input.Length + 1), (20 - input.Length-1));
}
Console.WriteLine(first);
 
 
My input is : Harish
Expected output is : HARISHXXXXXXXXXXXXXX 

Answers (2)