By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,340 Members | 1,418 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,340 IT Pros & Developers. It's quick & easy.

inherit from data types?

P: n/a
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

Nov 22 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 22 '05 #2

P: n/a
Cor
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
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?

Nov 22 '05 #3

P: n/a
Cor
>
A value is the property itself, in my opinion you are talking about a normal (data)class with a default value.

default value property
Nov 22 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.