Java |
Java primitives cannot be assigned to
reference types directly before Java 5.
class Test
{
public static void main(String[] args) {
int i = 123;
Object o = i; // error
int j = (int) o; // error
System.out.println(3.toString());//error
}
}
|
|
C# |
C# provides a "unified type system".
All types derive from the type object
class Test
{
static void Main() {
int i = 123;
object o = i; // boxing
int j = (int) o; // unboxing
Console.WriteLine(3.ToString());
}
}
|
|