Q:

how to auto generate number value in a textbox using c# and the number starts from 2001 in textbox?

public partial class Form1 : Form
{
    int billno=2000;
    string code;
    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        billno = Convert.ToInt32(code);
        billno = billno + 1;
        textBox1.Text = " "+ billno;

    }

A:

Try this
public partial class Form1 : Form
{
    static int billno=2000;
    string code;
    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        billno = billno + 1;
        textBox1.Text = billno.ToString();

    }

Here billno will increment by 1 on every Form load event.

