Jump to content


MACUL

Member Since 12/12/2003
Offline Last Active 18/12/2015, 16:24
-----

Topics I've Started

Isnumeric C#

26/09/2011, 18:34

using System;
using System.Text;
using System.Text.RegularExpressions;

private bool IsTextValidated(string strTextEntry)
{           
      System.Text.RegularExpressions.Regex objNotWholePattern = new System.Text.RegularExpressions.Regex("[^0-9]");
      return !objNotWholePattern.IsMatch(strTextEntry)
           && (strTextEntry != "");      
}



public static bool IsNumeric1(object numberString)
        {
            char[] ca = numberString.ToString().ToCharArray();
            for (int i = 0; i < ca.Length; i++)
            {
                if (!char.IsNumber(ca[i]))
                    if (ca[i] != '.')
                        return false;
            }
            if (numberString.ToString().Trim() == "")
                return false;
            return true;
        }


public static bool IsInteger(string theValue)
{
  try
  {
     Convert.ToInt32(theValue);
     return true;
  }
  catch
  {
     return false;
  }
}


public bool Isnumeric2(string numberString)
        {
             int resposta = 0;
             return System.Int32.TryParse(numberString, out resposta);
        }

IPB Skin By Virteq