473,837 Members | 1,729 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Extend System.Decimal?

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
Nov 21 '05 #1
2 1663
Frederik,

In my opinion can you create any class that holds the methods to do what you
want, however not create a new value type.

Cor

Nov 21 '05 #2
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

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
18701
by: Dave Robinson | last post by:
I was wondering if anyone could help me with a problem I'm having. I've been using Dreamweaver to create a hotel booking system for a friend of mine, using MySQL (version 4.0.21) and PHP 5. The bit I'm struggling with is checking the Room Availability based on dates that are typed into a textfield and then returning a list of the available rooms on the next page. The three tables involved in this function are: CREATE TABLE `room` (
2
3606
by: Carl G | last post by:
I am storing a 0.000 a System.Decimal in a DataRow. On retrieval the value is only 0 without the three decimal places. It looks like the Get property returns System.Decimal.Zero, but why???? I can't figure out why the design is so that the DataRow "alters" the value entered. In my application a decimal column in a row of a specific table has a fix number of decimal places according to certain premises. The
1
4366
by: Mike Chamberlain | last post by:
Hi all. I'm trying to extend the Microsoft Enterprise Library Data Access Application Block (http://msdn.microsoft.com/library/en-us/dnpag2/html/daab.asp?frame=true) to work with a Borland Interbase database. To do this, I copied and renamed the source files for working with a SQL Server database (SqlCommandWrapper.cs/SqlDatabase.cs to InterbaseCommandWrapper.cs/InterbaseDatabase.cs). I then changed all
2
1549
by: Joseph Turian | last post by:
Hi, What is the safest manner to extend search path for modules, minimizing the likelihood of shooting oneself in the foot? The system (which includes scripts and their shared modules) may be checked out in several different locations, but a script in a particular checked-out version of the system should only use modules from that checkout location.
1
2171
by: Ted | last post by:
I have some code which processes an xsd. For elements of type xs:integer the XmlSchemaDatatype object gotten from the schema elements ElementType member contains a ValueType of System.Decimal. I don't get it it should be System.Int32 or some other integer type but not a decimal. Any ideas why this is happening? btw: I'm using msxml 4.0. Ted
19
1478
by: Sput | last post by:
I am thoroughly frustrated with these seemingly unchangable settings in C#. For example, fetching data from database sorted by date returns wrong order (would be correct if I was using american date system). Same goes for sorting datagrid (sorts dates and decimal numbers - ie 31.12.2004 is sorted by first number instead of second and 100.000,00 is treated as text ). Is there a simple way of changing this or am I to write my own sorting...
2
2220
by: centrino | last post by:
hi, I want to extend System.Net.Sockets.ProtocolType to IPinIP protocol, how can i do that. Do i have to make new class or enum stuct for this type ? regards
9
2938
by: MDoyle | last post by:
Here is the easiest question you’ll get all day from a complete newbie. I installed Visual Studio on my laptop last night and have been tryin to write my very first C# programs this morning. I’m running into few issues that I’m sure someone on this forum will be able to help m understand quickly. I started out with a traditional “Hello World” program, again, my firs C# programs. I was surprised to see how the System namespace wa...
1
3084
by: patrick | last post by:
I have tried using 2 type systems to get this to compile but it still gets the same error: Public MustInherit Class _Applications Private _AppID As System.Decimal Private _AppPosition As System.Decimal Private _AppCompany As System.Decimal Private _AppWhen As System.DateTime Private _AppType As System.String Private _AppNotes As System.String
0
9696
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10902
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10288
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9420
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7824
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7014
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4481
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3128
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.