Possible Duplicate:
How do ValueTypes derive from Object (ReferenceType) and still be ValueTypes?
I am able to write the code like this,
String s = 10.ToString();
ToString() will only come when that particular object is inheriting class ‘Object'(ofcourse all the classes inherits Object in c#). Is it number 10 also inheriting the class ‘object’. If so how?
The literal
10is, per the specification, interpreted by the compiler as an instance ofInt32.Int32inherits fromobject. Thus,10is an instance of a type that inherits fromobject. As such, it has an instance method namedToString.