what is the use System.ValueType and System.Int32 ?? How come System.ValueType is a class whereas System.Int32 is structure ???
C sharp value types...
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
what is the use System.ValueType and System.Int32 ?? How come System.ValueType is a class whereas System.Int32 is structure ???
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
VulpesRank #55 · 29.2K reputationPosted May 26, 2013, 12:36 PM EDT
Enums inherit from System.Enum which in turn inherits from System.ValueType.
The purpose of System.ValueType is to override all the virtual methods in System.Object to provide implementations which are more appropriate for value types as opposed to reference types.
System.ValueType is also useful as a method parameter type if you want to be able to pass any value type to a method for some reason.
As structures are implicitly sealed and so can't be inherited from, System.ValueType needs to be a class rather than a structure.
System.Int32 represents a signed 4 byte integer with a range of approximately plus or minus 2 billion. 'int' is just an alias in C# for this type.