Checks whether the string starts with an alphabet or not : String Search « Data Types « C# / C Sharp






Checks whether the string starts with an alphabet or not

   
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace WebOssApplications.Common
{
    public static class Extensions
    {
        /// <summary>
        /// Checks whether the string starts with an alphabet or not
        /// </summary>
        /// <param name="value">Value to check</param>
        /// <returns>True if the string starts with an alphabet</returns>
        /// <exception cref="ArgumentNullException">Throws if value is null</exception>
        /// <exception cref="ArgumentOutOfRangeException">Throws if value is empty</exception>
        public static bool StartsWithAlphabet(this string value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            if (string.IsNullOrEmpty(value))
            {
                throw new ArgumentOutOfRangeException("value");
            }

            return char.IsLetter(value, 0);
        }

    }
}

   
    
    
  








Related examples in the same category

1.Search stringsSearch strings
2.use the IndexOf() and LastIndexOf() methods to search for substrings and characters;
3.String search: last indexString search: last index
4.String search DemoString search Demo
5.String split and searchString split and search
6.Ensure End With SemiColon
7.String Starts With
8.Checks whether the string starts with a number or not
9.Finds a given string and enclosing it with tags provided.