473,809 Members | 2,772 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Currency class

Java has this. Anyone know of a .Net equivalent?

Thanks,
Eric
Nov 30 '06 #1
5 8284
Eric wrote:
Java has this. Anyone know of a .Net equivalent?
What part of Currency do you need? Using a NumberFormatInf o object along
with the culture of choice will get you some of the functionality. Here is
an example of some of the values available:

NumberFormatInf o nf = CultureInfo.Cur rentCulture.Num berFormat;
int fractionDigits = nf.CurrencyDeci malDigits;
string symbol = nf.CurrencySymb ol;
string groupSeparator = nf.CurrencyGrou pSeparator;
string decimalSeparato r = nf.CurrencyDeci malSeparator;

I don't believe there is anything in .NET that will give you the currency
code.

Create a CultureInfo object for the culture of your choice if you want one
other than the current culture (ex: CultureInfo ci = new
CultureInfo("en-GB");). You can use the NumberFormatInf o object in calls to
Parse and Format methods on your numeric objects (int, decimal, double,
etc).
--
Tom Porterfield

Nov 30 '06 #2
Tom Porterfield wrote:
Eric wrote:
>Java has this. Anyone know of a .Net equivalent?

What part of Currency do you need? Using a NumberFormatInf o object along
with the culture of choice will get you some of the functionality. Here
is an example of some of the values available:

NumberFormatInf o nf = CultureInfo.Cur rentCulture.Num berFormat;
int fractionDigits = nf.CurrencyDeci malDigits;
string symbol = nf.CurrencySymb ol;
string groupSeparator = nf.CurrencyGrou pSeparator;
string decimalSeparato r = nf.CurrencyDeci malSeparator;

I don't believe there is anything in .NET that will give you the currency
code.

Create a CultureInfo object for the culture of your choice if you want one
other than the current culture (ex: CultureInfo ci = new
CultureInfo("en-GB");). You can use the NumberFormatInf o object in calls
to Parse and Format methods on your numeric objects (int, decimal, double,
etc).
The currency code is available in the RegionInfo class.

RegionInfo ri = new RegionInfo(Cult ureInfo.Current Culture.LCID);
string currencyCode = ri.ISOCurrencyS ymbol;
--
Tom Porterfield

Nov 30 '06 #3
It really is the currency code I'm after - I want to build a Money class
along the lines of Fowler's pattern. So what I would ideally like is an
enumeration of all the currency codes net knows about, anyone of which could
be an attribute of a given Money instance.

I found the RegionInfo.IsoC urrencyCode property, but couldn't figure out how
to get an enumeration out of it. If we had a class like Java's Currency I'd
have enough of the values and type safety I'm looking for.

Thanks,
Eric
"Tom Porterfield" <tp******@mvps. orgwrote in message
news:eX******** ********@TK2MSF TNGP02.phx.gbl. ..
Tom Porterfield wrote:
>Eric wrote:
>>Java has this. Anyone know of a .Net equivalent?

What part of Currency do you need? Using a NumberFormatInf o object along
with the culture of choice will get you some of the functionality. Here
is an example of some of the values available:

NumberFormatIn fo nf = CultureInfo.Cur rentCulture.Num berFormat;
int fractionDigits = nf.CurrencyDeci malDigits;
string symbol = nf.CurrencySymb ol;
string groupSeparator = nf.CurrencyGrou pSeparator;
string decimalSeparato r = nf.CurrencyDeci malSeparator;

I don't believe there is anything in .NET that will give you the currency
code.

Create a CultureInfo object for the culture of your choice if you want
one
other than the current culture (ex: CultureInfo ci = new
CultureInfo("e n-GB");). You can use the NumberFormatInf o object in calls
to Parse and Format methods on your numeric objects (int, decimal,
double,
etc).

The currency code is available in the RegionInfo class.

RegionInfo ri = new RegionInfo(Cult ureInfo.Current Culture.LCID);
string currencyCode = ri.ISOCurrencyS ymbol;
--
Tom Porterfield

Dec 1 '06 #4
On Thu, 30 Nov 2006 19:32:36 -0800, Eric wrote:
It really is the currency code I'm after - I want to build a Money class
along the lines of Fowler's pattern. So what I would ideally like is an
enumeration of all the currency codes net knows about, anyone of which could
be an attribute of a given Money instance.

I found the RegionInfo.IsoC urrencyCode property, but couldn't figure out how
to get an enumeration out of it. If we had a class like Java's Currency I'd
have enough of the values and type safety I'm looking for.
It would be tough, and not like java. You can get all the cultures by
accessing CultureInfo[] CultureInfo.Get Cultures(). You would then need to
build a RegionInfo object from each CultureInfo in the array and then get
the ISOCurrencySymb ol.
--
Tom Porterfield
Dec 1 '06 #5
Thanks Tom - that is pretty much what did the trick

"Tom Porterfield" <tp******@mvps. orgwrote in message
news:gu******** ******@tpporter mvps.org...
On Thu, 30 Nov 2006 19:32:36 -0800, Eric wrote:
>It really is the currency code I'm after - I want to build a Money class
along the lines of Fowler's pattern. So what I would ideally like is an
enumeration of all the currency codes net knows about, anyone of which
could
be an attribute of a given Money instance.

I found the RegionInfo.IsoC urrencyCode property, but couldn't figure out
how
to get an enumeration out of it. If we had a class like Java's Currency
I'd
have enough of the values and type safety I'm looking for.

It would be tough, and not like java. You can get all the cultures by
accessing CultureInfo[] CultureInfo.Get Cultures(). You would then need to
build a RegionInfo object from each CultureInfo in the array and then get
the ISOCurrencySymb ol.
--
Tom Porterfield

Dec 2 '06 #6

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

Similar topics

2
4630
by: Dennis | last post by:
I'm trying to output currency columns to the console in table format. I need a class that allows me to format doubles to currency and have the columns right-justified. I've come up with a ridiculously convoluted way to use MessageFormat() to do this, but there's got to be a better way. Is there a class that's good for this? There has to be. (I'm just learning my way around Java). Thanks.
2
574
by: Willing 2 Learn | last post by:
I'm still having trouble getting my program to do arithmetic in cents(keeping all #'s) then convert the answer in a format of dollars & cents. The main program should add, subtract, scalar multiply(by int)& show, have a constructor w/ & w/out arguments. Header file should have private data & all 6 functions from above.Class definition file should implement my ADT class. What I have so far: Main program #include "jahcurrency.h" #include...
2
1619
by: Paul Wistrand | last post by:
Hi, does anyone know if there are any opensource implemenations of an Currency class for the .NET framework?
2
1214
by: C CORDON | last post by:
I am creating a windows Class library Project, but it won't let me declare any var as Currency! Why is this? TIA! :)
1
1366
by: Doug Bell | last post by:
Hi, Hi had a DataGrid on a form and was using the CurrentCellChanged Event to determine the selected row: Private Sub grdSelOrd_CurrentCellChanged(ByVal sender As System.Object, _ ByVal e As System.EventArgs) dacGetDataGridRow() Dim intRow As Integer = CType(Me.BindingContext(grdSelOrd.DataSource), _
5
2460
by: Theodore | last post by:
Hi, i have a class "MyClass" with a public property of datatable type. I also have a form with a public property of type "MyClass". The form has a datagrid which binds to MyClass.Table datatable. While navigating through the datagrid rows i can see the current position of MyClass.Table object through the currency manager (ctype(bindingcontext(Myclass.Table), currencymanager).position). How can i see the current position from within...
2
4242
by: Octavio Hernandez | last post by:
Hi, I have a seemingly easy problem drivin' me nuts. I'd be grateful for any hint on what may be causing it. The fact is I'm developing an ASP.NET web site. At some point, I need to read a money amount from a DataReader. The line is: if (reader.Read()) { Currency c1 = (Currency) reader; // OFFENDING LINE
18
6196
by: Boris Yeltsin | last post by:
OK, I have a database table, it has prices of products in it, like so: ProductPrice MONEY ProductIsoCurrencyCode CHAR(3) Now, both CultureInfo and RegionInfo have currency-handling functions inside them, but I want to display the price on my web site given the information above, plus the current culture of the web site visitor. So, I have
3
7338
by: Eric | last post by:
I know this is a property of the RegionInfo class. I figure somewhere in the framework is the actual enumeration, which I would like to use. I want to use it to support a Money class I need, along the lines of Fowler, which would have an attribute of Currency. Any help much appreciated.
0
9601
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
10637
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...
1
10379
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10115
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
6881
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
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5687
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3014
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.