The problem is your asking for a count of the number of integers, in theory
your asking for the length of a set of characters. The fact that they are
numbers is irrelevent really.
Heres an example that doesn't care about whether the seperator is . or , or
whatever, but instead assumes that the first none numeric character of the
string in reverse is the seperator, and thus concludes the char count.
Double myVal = 5231.12231;
char[] reverse = myVal.ToString().ToCharArray();
Array.Reverse(reverse);
for (int i = 0; i < reverse.Length; i++){
if (!char.IsNumber(reverse
)){
Response.Write("Length is " + i);
}
}
--
--
Regards
John Timney (MVP)
VISIT MY WEBSITE:http://www.johntimney.comhttp://www.johntimney.com/blog
Hey John,
Tnx for your reaction.
Your example is one of the most slick methods, that I also have
considered, but there is still a ToString formatting going on.
BUT it seems as, according to reactions in other groups, that it is
nearly impossible to avoid the use of string formatting.
My worries towards the use of string formatting is based on the
differences in cultural string handling and the formatting of decimals
("," or ".").
But thanks for your example.
Take care
Regards,
Stefan
You could just split it apart, without any formatting
Double start_value = 5231.12231;
string[] end_values = start_value.ToString().Split('.');
int slen = end_values[1].Length;
Response.Write(slen);
John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.comhttp://www.johntimney.com/blog