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