T
Tony Johansson
Hi!
public static void Main()
{
//Here i is boxed. This is easy to understand.
int i = 44;
Object o = i;
ArrayList alist = new ArrayList();
alist.Add(44);
//Here I read the element from the ArrayList using object but where will the
unbox take place ???
// It must be done somewhere either in the foreach or in the WriteLine.
foreach (object o in alist)
{
Console.WriteLine(o);
}
//Here how is it possible to read from the ArrayList when there only exist
object because the int was boxed ?
foreach (int i in alist)
{
Console.WriteLine(i.GetType()); // this is of type System.Int32
Console.WriteLine(i);
}
}
//Tony
public static void Main()
{
//Here i is boxed. This is easy to understand.
int i = 44;
Object o = i;
ArrayList alist = new ArrayList();
alist.Add(44);
//Here I read the element from the ArrayList using object but where will the
unbox take place ???
// It must be done somewhere either in the foreach or in the WriteLine.
foreach (object o in alist)
{
Console.WriteLine(o);
}
//Here how is it possible to read from the ArrayList when there only exist
object because the int was boxed ?
foreach (int i in alist)
{
Console.WriteLine(i.GetType()); // this is of type System.Int32
Console.WriteLine(i);
}
}
//Tony