473,326 Members | 2,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Difference between 3 types of parsings for string to decimal

Whats the difference between :-

1. Convert.ToDecimal(stringNumber)
2. Decimal.Parse(stringNumber)
3. decimal.Parse(stringNumber)

Thanks.
Sushant Bhatia

Nov 16 '05 #1
3 5892
Sushant,

Can you give me an idea in what relation your question is placed.

Convert.ToDecimal(stringNumber);
this overloaded method from Convert.ToDecimal does probably exact the same
as
decimal.parse(stringNumber)

Decimal.Parse gives an error.

Cor
Nov 16 '05 #2
Hi Sushant Bhatia,

The Convert class is designed to convert a wide range of Types, so you can
convert more types to Decimal than you can with Decimal.Parse, which can
only deal with String. On the other hand Decimal.Parse allows you to
specify a NumberStyle.

Decimal and decimal are aliases and are equal.

For Convert.ToDecimal(string), Decimal.Parse is called internally.
On 13 Mar 2005 00:21:03 -0800, <su************@gmail.com> wrote:
Whats the difference between :-

1. Convert.ToDecimal(stringNumber)
2. Decimal.Parse(stringNumber)
3. decimal.Parse(stringNumber)

Thanks.
Sushant Bhatia


--
Happy Coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #3
<su************@gmail.com> wrote:
Whats the difference between :-

1. Convert.ToDecimal(stringNumber)
2. Decimal.Parse(stringNumber)
3. decimal.Parse(stringNumber)


Convert.ToDecimal returns 0m if you pass in null.
System.Decimal.Parse and decimal.Parse are exactly equivalent, as
decimal is just a C# shorthand for System.Decimal.

System.Decimal.Parse will throw an ArgumentNullException if you pass in
null.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #4

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

Similar topics

3
by: ling | last post by:
Hi, I'm trying to do fscanf from a file with integers. I've tried using both %d and %i hoping that I would figure out their difference. When I checked the man pages, the only difference I...
5
by: chenedor | last post by:
Hi all I am a bit confuse about unboxing... what is the difference and what is best practice ? object o = __box(1234); int n = *dynamic_cast<__box int*>(o); of
3
by: dan heskett | last post by:
Hello group, I am trying to get used to vb.net coming from a far far far away set of tools. What i want to do is setup an object in my application that contains other object types, that act...
8
by: Marc | last post by:
Hi! I'm calling a web service using C# and a wrapper class generated by wsdl tool. The web service specification contains some nillable parameters which types are Value Types in .NET (long, int,...
11
by: mesut demir | last post by:
Hi All, When I create fields (in files) I need assign a data type like char, varchar, money etc. I have some questions about the data types when you create fields in a file. What is the...
8
MMcCarthy
by: MMcCarthy | last post by:
Type MemSize RetVal of VarType() Declaration Char Conversion Boolean 2b vbBoolean(11) CBool() Byte 1b vbByte(17) ...
3
by: Wolfgang Meister | last post by:
In order to retrieve a NUMBER value out of a column from an Oracle Table iinto a local variable there are two functions: Decimal var = reader.GetDecimal(1); or Decimal var =...
8
by: Jesper Lund Stocholm | last post by:
I am currently working on converting an old .Net 1.1-application to .Net 3.5. Due to the lack of nullable datatypes in those days, a "decimal wrapper" was created that had various methods to parse...
1
by: Joey Fontaine | last post by:
I just noticed that, when using intellisense, the DateTime.MaxValue field has a static property icon whereas the Decimal.MaxValue field has a constant property icon. However, when looking at the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.