please help me in doing this

Recommended Answers

All 6 Replies

that is i want to create n number of labels using C# coding

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;
    }
}
for(int i=0;i<n;i++)
{
Label NewLabel = new Label();
NewLabel.ID ="Label"+i;
NewLabel.Text = "Label" + i;
this.form1.Controls.Add(NewLabel);
}

thanks geniusvishal & TimCadieux :):)

static int SumWhile()
{
    //
    // Sum numbers 0 .. 4
    //
    int sum = 0;
    int i = 0;
    while (i < 5)
    {
    sum += i;
    i++;
    }
    return sum;
}
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);
    }
    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.