Description :
Ingredients:
1) One List Box
2) One Button
Programming (Ascending Order):
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int A;
A = 1;
while (A < 10)
{
listBox1.Items.Add(A);
A++;
}
}
}
}
Result:
1 to 10
Programming (Descending Order):
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int A;
A = 10;
while (A > 1)
{
listBox1.Items.Add(A);
A--;
}
}
}
}
Result:
10 to 1
No comments:
Post a Comment