string a = "12.5"; bool HasDecimal = a.Contains('.'); if (HasDecimal == true) { int i = a.IndexOf('.'); int j = a.Length; int k = j - i; a = a.Substring(i, k); // now a contains only decimal value } else { //no decimal }
if(TestBox1.Text.Contains('.')&&TextBox1.Text.Split('.')[1].Length==1) { //code }
private static readonly Regex OneDecimalCheck = new Regex(@"\.\d$"); // .... if (OneDecimalCheck.IsMatch(TheTextBox.Text)) { // TheTextBox content Text ends with . followed by a digit. }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)