I am pulling the values from a database using a Querystring.
Example values:
1.1
2.1
10.1
11.1
Is there a way to format the string so that it onlys shows the numbers before the decimal point?
Ex. 1.1 = 1, 10.1 = 10, etc.
I tried the code below but it only shows the first number.
|
BrettPosted Aug 25, 2010, 11:50 AM
Andrew FensterPosted Aug 24, 2010, 10:03 PM
int x = strNumber.IndexOf("."); // Get the location of the decimal point.
if (x == -1) // -1 means there was no decimal point found.
Label1.Text = strNumber;
else
Label1.Text = strNumber.Substring(0, x); // Get all the characters to the left of the decimal point.