Advertisement
tolikpunkoff

IsDouble (code fragment)

Aug 9th, 2021
2,145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.49 KB | None | 0 0
  1.         private bool IsDouble(string st)
  2.         {
  3.             st = st.Replace('.', separator);
  4.             st = st.Replace(',', separator);
  5.             NumberFormatInfo format = new NumberFormatInfo();
  6.             format.NumberDecimalSeparator = separator.ToString();
  7.  
  8.             try
  9.             {
  10.                 double d = Convert.ToDouble(st, format);
  11.                 return true;
  12.             }
  13.             catch
  14.             {
  15.                 return false;
  16.             }
  17.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement