473,406 Members | 2,707 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,406 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 5908
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
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,...
0
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...

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.