Mega Code Archive

 
Categories / C# / Data Types
 

Checks if the string starts with special character This does not include any special character from AllowedSpecialCharacters.tx

using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace WebOssApplications.Common {     public static class Extensions     {         /// <summary>         /// Checks if the string starts with special character. This does not include any special character from <see cref="AllowedSpecialCharacters"/>         /// </summary>         /// <param name="value">Value to check</param>         /// <returns>True if the string starts with a special character</returns>         /// <exception cref="ArgumentNullException">Throws if value is null</exception>         /// <exception cref="ArgumentOutOfRangeException">Throws if value is empty</exception>         public static bool StartsWithSymbol(this string value)         {             if (value == null)             {                 throw new ArgumentNullException("value");             }             if (string.IsNullOrEmpty(value))             {                 throw new ArgumentOutOfRangeException("value");             }             return char.IsSymbol(value, 0) || char.IsPunctuation(value, 0);         }     } }