Skip to content

StringConversionExtensions Class ​

Definition ​

Extension methods for conversion operations on the string datatype

  • Namespace: JASE.Extensions
  • Assembly: JASE.Primitives.dll

Methods ​

NameDescription
string Base64Decode(string input)Attempts to decode a base64 string
string Base64Encode(string input)Attempt so encode a string to Base64
byte[] FromHex(string input)Converts a hexadecimal string into a byte array.
string Quote(string input, char quoteChar = null, bool trimInput = null)Returns string surrounded by Quote characters
IEnumerable<string> ReadByLine(string input)Yields a string on a line delimiter basis
string RemoveDiacritics(string input, bool normalize = null)Normalize a string by removing Diacritics
string RemoveNonDigits(string input)Removes all non-digit characters from the input string, useful in converting telephone #'s
string Reverse(string input)Returns the reverse of the input string
string Slice(string source, int start, int end)Get the string slice between the two indexes. Inclusive for start index, exclusive for end index. Mimics the JavaScrip implementation
IList<string> SplitAndKeepDelimiters(string s, char[] delimiters)Split string into IList but retain the delimiters in the resulting values
List<string> SplitAndTrim(string input, char separator, bool removeEmpties = null)Splits string on defined separator and trims results
string StripHTML(string input)Attempts to remove all HTML like tags from a string using RegEx
byte[] ToByteArray(string input, Encoding encoding = null)Converts string to byte array based on appropriate Encoding
T ToEnumValue(string enumerationDescription, bool caseSensitive = null)Attempts to convert the provide string to a enum value
object ToEnumValue(string enumerationDescription, Type type)Convert a strings value to the Enum value of type
object ToEnumValue(string enumerationDescription, Type type, bool caseSensitive)Convert a strings value to the Enum value of type with optional case sensitivity
string ToHex(string input)Converts an input string a hex string value
int[] ToIntArray(string input)Converts a string of numbers into an integer array
List<string> ToList(string input)Returns a list of strings delimited by line
List<string> ToListByLine(string input)Deprecated version of ToList
string ToMaxLength(string input, int length, Encoding encoding = null)Truncates string down to a maximum length
SecureString ToSecureString(string input, bool readOnly = null)Converts a string to its SecureString equivalant
Stream ToStream(string input)Converts a string to a Stream
List<string> ToWords(string input, bool keepDelimiters = null, bool unquoteText = null, char[] splitChars = null)Returns a string list based on logical sentence breakpoints
string Unquote(string input, char quoteChar = null, bool trimInput = null, bool trimOutput = null)Remove wrapping quote characters from a string