|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Strong Typing of Primitive TypesWe would like to create strong types to provide more compile time error
control. For example we would like salary to be from a salary class, temperature to be from a temperature class, age to be from an age class, etc. However, these would be have like decimals, integers, etc. Are there classes hiding somewhere like 'Integer', 'Decimal', etc. that would allow an inherited class to be derived that had all the behavior of the primative type but was type safe? Thanks, David Maybe I'm missing something, but why not just wrap the primitive types with
your own names? class Salary : decimal { // look, Ma, no work necessary! } Show quoteHide quote "DavidNJ" <Davi***@discussions.microsoft.com> wrote in message news:D748FE18-F68C-4857-B63D-D480D9676909@microsoft.com... > We would like to create strong types to provide more compile time error > control. For example we would like salary to be from a salary class, > temperature to be from a temperature class, age to be from an age class, > etc. > > However, these would be have like decimals, integers, etc. > > Are there classes hiding somewhere like 'Integer', 'Decimal', etc. that > would allow an inherited class to be derived that had all the behavior of > the > primative type but was type safe? > > Thanks, > > David Marcos,
>Maybe I'm missing something, but why not just wrap the primitive types with You can't derive from value types.>your own names? > >class Salary : decimal { Mattias -- Mattias Sjögren [MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup.
Other interesting topics
How to dynamically load strong name assemblies
How to disable .NET Framework 2.0 Protecting Assembly against disassembling... Events & Delegates streamreader halt Process.Start - The requested lookup key was not found in any active activation context. simple confirmation on XML comments ... Checking whether "SomeString" is Directory or File... Any hints on how to use the MvpSerializerFormatter with EntLib? Checking Drive for Ready and for Type |
|||||||||||||||||||||||