I've been looking for the past few days on how to do this but I just can't figure out what the correct way to assign a variable that will stay with the class

Any help will be appreciated.

private void button1_Click(object sender, EventArgs e)
        {
            tempclass tempclass = new tempclass();

            Thread t = new Thread(tempclass.add);
            string[] stuff = {"one 1", "two", "three"};
            t.Start(stuff);

            tempclass.show();
        }

     }

    class tempclass
    {
        public string data;

        public void add(object param)
        {
            string[] pams = (string[])param;
            MessageBox.Show(pams[0]);
            data = pams[0];
        }

        public void show()
        {
            MessageBox.Show(data);
        }
    }

Use BackgroundWorker component which is use for multithreading tasks you can call the method by name and send the parameters in array of objects.

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.