PrintStarTriangle



   private void button1_Click(object sender, EventArgs e)
        {
            label1.Text = "";
           
            int n = Convert.ToInt32(textBox2.Text);
            PrintStarTriangle(n);
         
        }

        public void PrintStarTriangle(int level)
        {
            int lastdigit = (2 * (level - 1) + 1); // last roe digit
            for (int i = 0; i < level; i++)
            {
                int value = (2 * i) + 1;
                int scapevalue = (lastdigit - value) / 2;
                for (int j = 0; j < lastdigit; j++)
                {
                    if (j < scapevalue)
                    {
                        label1.Text = label1.Text + "L ";
                    }
                    else
                    {
                        if (value > 0)
                        {
                            label1.Text = label1.Text + "* ";
                        }
                        value--;
                    }
                }
                label1.Text = label1.Text + Environment.NewLine;
            }
            label1.Text = label1.Text.Replace("L", " ");
        }

Comments