Hello everyone,
When dealing with value types, I met with two conflicting points,
1. We can not inherit one value type from another, for example, we can not make a struct inherit from another struct; -- I think it means there is no inheritance or derivation for value types.
2. All value types are inherits from ValueType, and ValueType is inherits from Object, seems value types could have inheritance or derivation?
How do you understand the two conflicting points? :-)
thanks in advance,
George
George GeorgePosted May 9, 2008, 6:13 AM
Thanks Awadhesh,
Question answered.
regards,
George
Awadhesh PratapPosted May 9, 2008, 5:57 AM
Both are the same struct ( represnting 32 bit Integer )
System.Int32
I think int is a shorthand for writing Int32 which is one of the available integer type.
Int16
Int32
Int64
George GeorgePosted May 9, 2008, 3:55 AM
Thanks Alan,
One further question, I think for primitive types, there are pairs of relationship, example int and Int32 are the same thing, only different in names. Is my understanding correct (I can not find answers from any books or search)?
regards,
George
AlanPosted May 8, 2008, 3:56 PM
1. No you can't derive from a struct.
2. ValueType from which all structs derive is in fact an abstract class, not a struct, so there's no inconsistency here.