A
Andrew Gniadek
Hey,
just going through "C# for Java Developers" by Jones&Freeman and I've
got a quick question about one of their examples. They give a simple
example of converting an instance of a value type to an object:
// Box an int variable
int myInt = 100;
object myIntObject = myInt;
System.Console.WriteLine("myIntObject = " + myInt.ToString());
Just curious if what they meant to do is
System.Console.WriteLine("myIntObject = " + myIntObject.ToString());
because wouldn't calling ToString() on myInt just use implicit boxing
making the statement
object myIntObject = myInt;
unnecessary?
Thanks,
A.
just going through "C# for Java Developers" by Jones&Freeman and I've
got a quick question about one of their examples. They give a simple
example of converting an instance of a value type to an object:
// Box an int variable
int myInt = 100;
object myIntObject = myInt;
System.Console.WriteLine("myIntObject = " + myInt.ToString());
Just curious if what they meant to do is
System.Console.WriteLine("myIntObject = " + myIntObject.ToString());
because wouldn't calling ToString() on myInt just use implicit boxing
making the statement
object myIntObject = myInt;
unnecessary?
Thanks,
A.