Display textbox value as decimal from Code behind as "10.20"

Posted by Sathya4260 under C# category on | Points: 40 | Views : 9723

Here is the simple code the show the text box values in the format 0.00

Let take textbox1, I am going to do some calculation and display the output in the format 0.00
Double a=10.2;
Double b=10;
Double sum=a+b;



Output : 20.20

Comments or Responses

Posted by: T.saravanan on: 3/9/2011 Level:Silver | Status: [Member] [MVP] | Points: 10
Hi Sathish Kumar S,

But small correction in your code..
textbox1.Text =sum.ToString("N2"); 

textbox1.Text =sum.ToString("#0.00");

Because C# is Case Sensitive Language.
Posted by: Sathya4260 on: 3/10/2011 Level:Starter | Status: [Member] | Points: 10
Thanks for reminding...

I think we r not going to compile the code here itself, anyway IntelliSense would do for us to write the correct code

Just for fun...
Posted by: T.saravanan on: 3/10/2011 Level:Silver | Status: [Member] [MVP] | Points: 10
Of course we can not compile the code here.If any one copy a code and paste into Visual Studio then compile means its thrown error.Then only i suggest the correction...

Login to post response