|
-
Apr 11th, 2006, 03:18 PM
#1
Thread Starter
Hyperactive Member
type casting error..
In an arraylist, I have some integers and some string data types.
I would like to display them on console. I am using the following code and it doesn't work.
ArrayList Simexcurve = new ArrayList();
Simexcurve.Add(8);
Simexcurve.Add("Hello world");
Simexcurve.Add(3.145678);
foreach (int n in Simexcurve)
Console.WriteLine(n.ToString());
I get an error at console.WriteLine saying "specified cast is not valid" when it tries to display "hello workd"
there is some typ casting that I should do since 'n' is declared as an int and "hello world" is a string.
can someone guide me how to display?
thanks
nath
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|