Strong Typing of Primitive Types

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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!
}
 
Marcos,
Maybe I'm missing something, but why not just wrap the primitive types with
your own names?

class Salary : decimal {

You can't derive from value types.



Mattias
 
Back
Top