473,606 Members | 2,101 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can Convert.Int32 handle Thousands separator?

I want to know if a call to Convert.Int32 can handle a Culture specific
string.

I have the following code:

string sText = "111,111,11 1";
int i;

i = Convert.Int32( sText );

This throws an exception.

So I try adding the following:

CultureInfo ci = Thread.CurrentT hread.CurrentCu lture;

i = Convert.Int32( sText, ci.NumericInfo );

This also throws.

Do I have to remove the Thousands Separator character myself?
Nov 15 '05 #1
3 7762
Hi Tim,

Suggest:

string sText = "111,111,11 1";
int i;

i = Int32.Parse(sTe xt, NumberStyles.Al lowThousands);

Regards,
Dan

"Tim Osborne" <Ti*********@xc ellenet.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
I want to know if a call to Convert.Int32 can handle a Culture specific
string.

I have the following code:

string sText = "111,111,11 1";
int i;

i = Convert.Int32( sText );

This throws an exception.

So I try adding the following:

CultureInfo ci = Thread.CurrentT hread.CurrentCu lture;

i = Convert.Int32( sText, ci.NumericInfo );

This also throws.

Do I have to remove the Thousands Separator character myself?

Nov 15 '05 #2
Tim,

On the culture you are using, check the NumberFormat property. On the
NumberFormatInf o instance returned, check the NumberGroupSepa rator property
to see the character used to separate groups.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Tim Osborne" <Ti*********@xc ellenet.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
I want to know if a call to Convert.Int32 can handle a Culture specific
string.

I have the following code:

string sText = "111,111,11 1";
int i;

i = Convert.Int32( sText );

This throws an exception.

So I try adding the following:

CultureInfo ci = Thread.CurrentT hread.CurrentCu lture;

i = Convert.Int32( sText, ci.NumericInfo );

This also throws.

Do I have to remove the Thousands Separator character myself?

Nov 15 '05 #3
I got there about the same time as you did.

Actually I went with NumberStyles.Nu mber.

Thanks a lot for the quick response though.

"Daniel Pratt" <ko************ ******@hotmail. com> wrote in message
news:uh******** ******@TK2MSFTN GP12.phx.gbl...
Hi Tim,

Suggest:

string sText = "111,111,11 1";
int i;

i = Int32.Parse(sTe xt, NumberStyles.Al lowThousands);

Regards,
Dan

"Tim Osborne" <Ti*********@xc ellenet.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
I want to know if a call to Convert.Int32 can handle a Culture specific
string.

I have the following code:

string sText = "111,111,11 1";
int i;

i = Convert.Int32( sText );

This throws an exception.

So I try adding the following:

CultureInfo ci = Thread.CurrentT hread.CurrentCu lture;

i = Convert.Int32( sText, ci.NumericInfo );

This also throws.

Do I have to remove the Thousands Separator character myself?


Nov 15 '05 #4

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

Similar topics

16
25862
by: Douglas | last post by:
Gday, How would I format a number so that: TheValue = 32500 Displays in the TextBox as: $32,500.00
2
5632
by: Alberto | last post by:
I have in a int32 a value and a want to show it in a label in this format: 1,234. I know there is an overload to the ToString method who has a string format. Which is string to see the numbers with the comma in the thousands? Thank you.
1
14622
by: Woodies_46 | last post by:
Ok i know this is simple but i just don't know the syntax. What I have is a bunch of values and i want to be able to display them as money values with a $ in front. eg. 16000000 1000 160000
4
4556
by: Joao Tomas | last post by:
Please, can someone help me to translate this single function to VB.NET ? ' DECLARATIONS Private Const BMP_MAGIC_COOKIE As Short = 19778 Private Structure BITMAPFILEHEADER '14 bytes Dim bfType As Short
11
15370
by: Yaniv | last post by:
Hi How can I convert Uint32 variable to System.drawing.color ?? Thanks in advanced Yaniv
8
6255
by: =?Utf-8?B?V2hpdG5leSBLZXc=?= | last post by:
Hi there, I'm having a bit of trouble using an HRASCONN object as a class member variable inside my managed C++ class. When I call RasDial() and pass in the address of my HRASCONN object, I get the following compiler error from Visual C++ 2005: error C2664: 'RasDialW' : cannot convert parameter 6 from 'cli::interior_ptr<Type>' to 'HRASCONN *'
2
2104
by: Nicolai.Schoenberg | last post by:
When i try it like you say, he ignores the dot. For example s = "12.45"; d = double.Parse(s); d will be 1245.0 :( pls help
0
2213
by: Piotrekk | last post by:
Hi I have an dword array returned by send message with TBM_GETPTICS Message. Thus i need to convert IntPtr to managed block of memory ( Int32 because od dword ). I tried saveral ways but it doesnt work:
4
2563
by: Yoavo | last post by:
Hi, I want to convert a string to double. I use the function: "System.Convert.ToDouble". The problem is that if the string contains the character "." the program aborts. What might be the problem ? Yoav.
0
7942
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
8429
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8084
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
8300
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
6761
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...
0
5461
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();...
1
2443
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
1
1550
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1287
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.