Cutting a string down to size.

CaJack's Avatar
Go4Expert Member
Hi,
I'm having trouble displaying numbers like 10.9900 as 10.99. My sql database holds the numbers such as 10.9900 and when I'm using my site i want the page to retrieve the number but cut the 2 zeros off of the end. I've found a way of cutting out the first 2 numbers...

Code:
testString.Substring(testString.length - 2)
But i cant seem to make it cut out the last 2 numbers, can anyone help?
Thanks.
0
pradeep's Avatar, Join Date: Apr 2005
Team Leader
Try this
Code: CSharp
testString.ToString("n2");
0
CaJack's Avatar
Go4Expert Member
Hi, That works perfect. What does it do exactly? does it do something on the database level? I've never come across this before and its quite interesting. Thanks.
0
pradeep's Avatar, Join Date: Apr 2005
Team Leader
That just formats the string to have 2 decimal places, simple! :-D