5
Contributors
6
Replies
19
Views
5 Years
Discussion Span
Last Post by baig123
1

I wrote this without being able to test it, but it should at least get you started.
Insert a placeholder into the HTML where you want the Labels to appear, then use this code.

{
    int x = 5;

    while (0 == (x - 1)) {
        Label myLabel = new Label();

        myLabel.ID = "myLabel_" + x;
        myLabel.Text = "Label No. " + x;

        PlaceHolder1.Controls.Add(myLabel);
        x += x;
    }
}
2
for(int i=0;i<n;i++)
{
Label NewLabel = new Label();
NewLabel.ID ="Label"+i;
NewLabel.Text = "Label" + i;
this.form1.Controls.Add(NewLabel);
}

Edited by geniusvishal

0
static int SumWhile()
{
    //
    // Sum numbers 0 .. 4
    //
    int sum = 0;
    int i = 0;
    while (i < 5)
    {
    sum += i;
    i++;
    }
    return sum;
}
0
using System;

class Program
{
    static void Main()
    {
    //
    // Shows five 'for int i' loops.
    //
    Console.WriteLine("--- For 1 ---");
    for (int i = 0; i < 10; i++)
    {
        Console.WriteLine(i);
    }
    Console.WriteLine("--- For 2 ---");
    for (int i = 10 - 1; i >= 0; i--)
    {
        Console.WriteLine(i);
    }
    Console.WriteLine("--- For 3 ---");
    for (int i = 0; i < 10; i += 2)
    {
        Console.WriteLine(i);
    }
    Console.WriteLine("--- For 4 ---");
    for (int i = 10 - 1; i >= 0; i -= 2)
    {
        Console.WriteLine(i);
    }
    Console.WriteLine("--- For 5 ---");
    for (int i = 0; i < (20 / 2); i += 2)
    {
        Console.WriteLine(i);
    }
    }
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.