inherit from data types?

  • Thread starter Thread starter Gabe Moothart
  • Start date Start date
G

Gabe Moothart

I would like to create slightly modified 'custom' data types. For
instance, a 'Degree' type, which behaves exactly like a double, except
that it has an extra property 'ToRadians'. Or, a 'phone' data type which
behaves exactly like a string, except that it has an extra property,
'FormatPhone', which ensures that the format is correct.

Is there a way to inherit from data types, so that I can simply add my
own custom properties?

TIA,
Gabe
 
Gabe,
Is there a way to inherit from data types, so that I can simply add my
own custom properties?

You can't inherit from double because it's a value type, and you can't
inherit from string because it's sealed.



Mattias
 
Hi Gabe,

When something has a property it is no value.

A value is the property itself, in my opinion you are talking about a normal
(data)class with a default value.

Cor
 
Back
Top