Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.53 KB | None | 0 0
  1.         public static int NumberOfDecimalPlaces(string number)
  2.         {
  3.             if (number.Contains(DecimalSymbol))
  4.             {
  5.                 string[] numbersplit = number.Split(charDecimalSymbol);
  6.                 return numbersplit[1].ToString().Length;
  7.             }
  8.             else
  9.             {
  10.                 return 0; //no decimal places.
  11.             }
  12.         }
  13.  
  14.         public static int NumberOfDecimalPlaces(int number)
  15.         {
  16.             return NumberOfDecimalPlaces(number.ToString());
  17.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement