Link to home
Create AccountLog in
Avatar of njgroup
njgroup

asked on

casting problem in c#

him,

I have this code snippet:

        public void DisplayXMLInfo(string xml_visitor_path, Form1 frm)
        {
            object[] args = new object[] { xml_visitor_path, frm };
            DisplayXMLInfoThread = new Thread(new ParameterizedThreadStart(DisplayXMLInfoThFr));
            DisplayXMLInfoThread.Start(args);
        }

        public void DisplayXMLInfoThFr(object arg)
        {
            object[] args = new object[] { arg };
            string xml_visitor_path = (string)args[0];
            Form1 frm = (Form1)args[1];
            //other code
         }


the problem in these two lines:
            string xml_visitor_path = (string)args[0];
            Form1 frm = (Form1)args[1];

it gives runtime error: unable to cast,  so can anyone help me to solve this using generics?
SOLUTION
Avatar of rnevet
rnevet
Flag of Israel image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
ASKER CERTIFIED SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
ArrayList is a special type of class Available in the namespace : System.Collections which is used to store multiple objects of different DataTypes together.. all are stored in object form so u need explicit casting while using them again in code :) Hope this was helpful to you..
make it simple to avoid confusion.. :)