finding a character in a string

  • Thread starter Thread starter Mike P
  • Start date Start date
M

Mike P

How do you find a particular character in a string in C#? I have a
string which may be a whole number (1, 10, 100 etc), or a number with 1
or 2 decimal places. I need to check if the string has a decimal point,
and pad the string out to 2 decimal places using PadRight. But how do I
check for the decimal point, and count how many characters come after
it?


Any assistance would be really appreciated.


Cheers,

Mike
 
Mike P said:
How do you find a particular character in a string in C#? I have a
string which may be a whole number (1, 10, 100 etc), or a number with 1
or 2 decimal places. I need to check if the string has a decimal point,
and pad the string out to 2 decimal places using PadRight. But how do I
check for the decimal point, and count how many characters come after
it?

Use String.IndexOf(char).
 
Back
Top