Logo 
Search:

C# Answers

Ask Question   UnAnswered
Home » Forum » C#       RSS Feeds
  Question Asked By: Srikanth Kothagari   on Feb 09 In C# Category.

  
Question Answered By: Vivek Patel   on Feb 09

Take 3 controls on windows form 1) Textbox Control named textbox1 (For UserInput) 2) Button Control named button1 3) Label Control named lblOutput (For Output) Double click on button control and add following code for your button1_click event.


private void button1_Click(object sender, EventArgs e)
{            
    string UserInput = textBox1.Text;

    StringBuilder sbVertical = new StringBuilder();
    StringBuilder sbHorizontal = new StringBuilder();

    for (int i = 10; i > 0; i--)
    {
        sbHorizontal.Clear();
        for (int j = 0; j < i; j++)
        {
            sbHorizontal.Append(UserInput);
        }
        sbVertical.Append(sbHorizontal.ToString());
        sbVertical.Append("\n");
    }

    lblOutput.Text = sbVertical.ToString();
}

Share: 

 
 
Didn't find what you were looking for? Find more on using text box Or get search suggestion and latest updates.


Tagged: