Validates the char is 0-9 - CSharp System

CSharp examples for System:Char

Description

Validates the char is 0-9

Demo Code


using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*from w  w  w .  ja  v a2s  . c  o m*/

public class Main{
        /// <summary>
		/// Validates the char is 0-9
		/// </summary>
		public static bool IsUnsigned(this char c)
		{
			return char.IsDigit(c);
		}
        #region String and Char validation extensions

		/// <summary>
		/// Validates all chars are 0-9
		/// </summary>
		public static bool IsUnsigned(this string str)
		{
			if (string.IsNullOrWhiteSpace(str))
			{
				return false;
			}

			return str.All(IsUnsigned);
		}
}

Related Tutorials