Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static double Value_check()
- {
- bool was_point = false;
- string check = System.Console.ReadLine();
- for (int i = 0; i < check.Length; i++)
- {
- if (check[i] == '.' || check[i] == ',' && !was_point)
- {
- check = check.Remove(i, 1);
- check = check.Insert(i, ",");
- was_point = true;
- }
- else if (check[i] == '.' || check[i] == ',' && was_point)
- {
- check = check.Remove(i, 1);
- i--;
- }
- if ((check[i] < 48 && check[i] != 43 && check[i] != 44 && check[i] != 45 && check[i] != 0) || check[i] > 57)
- {
- check = check.Remove(i, 1);
- i--;
- }
- }
- if (check.Length == 0)
- {
- return 0;
- }
- return System.Convert.ToDouble(check);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement