# what is difference betweent

Posted by Cnagasa under C# on 2/13/2012 | Points: 10 | Views : 1325 | Status : [Member] | Replies : 7
hi every one,

what is difference betweent Convert.ToDouble and Double.Parse

Regard's
Sudarshan

sudarshan.c

#### Responses

Posted by: Pradeepkumar417 on: 2/13/2012 [Member] Starter | Points: 25
 0 Hi, Convert.ToDouble : You can convert any value to double by using this. Double.Parse : You can convert only string representation of a number in a specified style by using this.Thanks & Regards, Software Engineer, Pradeep KumarCnagasa, if this helps please login to Mark As Answer. | Alert Moderator
Posted by: Cnagasa on: 2/13/2012 [Member] Starter | Points: 25
 0 hi, thanking u for given the reply can u send me the 1 Example Regard's Sudarshan.Csudarshan.cCnagasa, if this helps please login to Mark As Answer. | Alert Moderator
Posted by: Pradeepkumar417 on: 2/13/2012 [Member] Starter | Points: 25
 0 Hi, Try this below example int i = 1; double d = Convert.ToDouble(i); string num = "4"; double d1 = Double.Parse(num); Thanks & Regards, Software Engineer, Pradeep KumarCnagasa, if this helps please login to Mark As Answer. | Alert Moderator
Posted by: Gow.net on: 2/13/2012 [Member] Starter | Points: 25
 0 ``` int i = 1; double d = Convert.ToDouble(i); Console.WriteLine(d); string num = "4"; double d1 = Double.Parse(num); Console.WriteLine(d1); string j = "1"; double f = Convert.ToDouble(j); Console.WriteLine(f); // Error // int z = 1; // double d2 = Double.Parse(z); // Console.WriteLine(d2);``` gowthaman8870226416Cnagasa, if this helps please login to Mark As Answer. | Alert Moderator
Posted by: Nvm on: 2/13/2012 [Member] Starter | Points: 25
 0 HI Sudarshan, Main Deference is, Conver.ToDouble(Value) is capable to handle null values, But Double.Parse(Value) through exception. Thank you NVMCnagasa, if this helps please login to Mark As Answer. | Alert Moderator
Posted by: Naraayanan on: 2/13/2012 [Member] Starter | Points: 25
 0 Hi, ConvertTo.Double returns 0 when nothing is passed, whereas Double. Parse throws an exception. Regards, Lakshmi Naraayanan.S http://dotnettechrocks.blogspot.in/ http://abaprocker.blogspot.com/Cnagasa, if this helps please login to Mark As Answer. | Alert Moderator
Posted by: Sabarimahesh on: 3/20/2012 [Member] Bronze | Points: 25
 0 I wonder if somebody could explain me the difference between Double.Parse and Convert.ToDouble. If I'm not mistaken they are implemented differently (I though for a moment they might be the same like cint(anInt) and cType(anInt, System.Int32) but I checked with ildasm) - if I didn't made a mistake. So when to use which syntax? Is there any performance penalty when using the one over the other or does anybody knows any differences? ```I want to assign to a variable in my code and assignt this to that variable. double Number1= (double)Txt_Number1.text; Error I want to assign to a variable in my code and assignt this to that variable. double Number1= (double)Txt_Number1.text;``` Life is a Race Thanks & Regards By Sabari Mahesh P MCnagasa, if this helps please login to Mark As Answer. | Alert Moderator
Latest Posts