How can Pass List to a constructor, I trying like this

    private void button1_Click(object sender, EventArgs e)
    {
        step2 st2 = new step2(list);
    }  

But what to write in constructor definition

    public step2()
    {
        InitializeComponent();
    }

Any suggestion is welcome

Recommended Answers

All 2 Replies

Overload the step2 constructor and use
public step2(List<string> mylist):this()
The special this syntax will invoke your normal constructor. In the body of this second constructor you can do with mylist what you want.

You put this way the contructor

public step2(List<string> list)
    {
        InitializeComponent();
        List<string> miLista = list;
    }
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.