Fredrick,
Decimal, being a Structure is a value type, which work the same as
NotInheritable Classes. Which means you cannot extend it directly, you would
need to encapsulate it and delegate all the methods to the real structure.
You can define MyDecimalX as a Structure and it will have all the value type
semantics of the Decimal type. However you will need to wait for VS.NET 2005
(aka Whidbey, due out in 2005) to support overloaded operators. Which will
allow your MyDecimalX to support +, -, /, * and other operators that you
define.
For a quick intro to overloading operators in VB.NET see:
http://blogs.gotdotnet.com/cambecc/p...1-127195cceeab
Overloading operator CType allows you to define custom conversions, for
example Decimal to & from MyDecimalX, allowing:
Dim d As Decimal
Dim md As MyDecimalX
d = md ' Widening Operator CType
md = CType(d, MyDecimalX) ' Narrowing Operator CType
FYI: VB.NET 2002 & 2003 knows about the Decimal type, so we are currently
able to use its overloaded operators directly. With VB.NET 2005 we will be
able to make use of the overloaded operators on any type in the Framework,
such as DateTime & TimeSpan.
Hope this helps
Jay
"Fredrik Melin" <me*@n.o.spam.d acsa.net.remove .as.needed> wrote in message
news:ex******** ******@TK2MSFTN GP12.phx.gbl...
Is there any way to extend or write a own "System.Decimal "?
In the doc its declared as
<Serializable >
Public Structure Decimal
Implements IFormattable, IComparable, IConvertibleBut how do you get
the functionallity that you can do Dim x as mydecimalx = 100Is that possible
or can only microsoft do stuff like that?RegardsFre drik