Click or drag to resize

Utils_String Class

String utilities.
Inheritance Hierarchy
SystemObject
  MicaSystems.UtilsUtils_String

Namespace:  MicaSystems.Utils
Assembly:  MicaSystems.Utils (in MicaSystems.Utils.dll) Version: 1.0.0.0 (1.1.0.123)
Syntax
C#
public static class Utils_String

The Utils_String type exposes the following members.

Methods
  NameDescription
Public methodStatic memberAddLine(String, String)
Returns a string equal to : str + carrage return char + new line char + newLine.
Public methodStatic memberAddLine(String, String, String)
Returns a string equal to : str + carrage return char + new line char + newLine formatted with parameters.
Public methodStatic memberAddLines
Returns a string containing all parameters separated with carrage return and new line characters
Public methodStatic memberAppend
Appends multiple strings to the end of the builder instance.
Public methodStatic memberAppendLine
Appends multiple strings followed by the default line terminator to the end of the builder instance.
Public methodStatic memberAppendList
Appends multiple strings to the end of the builder instance.
Public methodStatic memberCamelCaseToDisplay
Converts a Camel case text to a displayable text. E.g. "HelloWorld" becomes "Hello world".
Public methodStatic memberCompare
Compares two arrays of bytes.

Note : this method uses SequenceEqual method but will not fail if one or both arrays are null.

Public methodStatic memberContains
Checks if a string contains another string. (Uses s.IndexOf method)
Public methodStatic memberContainsAny
Checks if a string contains any of the specified strings.
Public methodStatic memberContainsExact

This method will split the string into multiple parts using given separators.

Public methodStatic memberContainsNewLine
Checks if the string contains a new line character '\n'.
Public methodStatic memberConvertToEnumT(String)
Returns an enum value obtained from a matching text.
Public methodStatic memberConvertToEnumT(String, T)
Returns an enum value obtained from a matching text.
Public methodStatic memberCreateLines
Returns a string containing all parameters separated with carrage return and new line characters
Public methodStatic memberCutOrPadRight
Cuts the given string if it's too long or fill it with spaces.
Public methodStatic memberDecryptString
Fast aes decryption method. CicpherText should contain IV and cipher in base64 encoding. Do not use for heavy work because of memory implications. Key must be between 128 and 256 bits long.
Public methodStatic memberDeserializeJson(String, Type)
Deserializes an object using a DataContractJsonSerializer.
Public methodStatic memberDeserializeJsonT(String)
Deserializes an object using a DataContractJsonSerializer.
Public methodStatic memberDeserializeJsonT(String, DataContractJsonSerializerSettings)
Deserializes an object using a DataContractJsonSerializer.
Public methodStatic memberDeserializeJsonT(String, Type, ListType)
Deserializes an object using a DataContractJsonSerializer.
Public methodStatic memberEncryptString
Fast aes encryption method. Returns IV and cipherText in base64 encoding. Do not use for heavy work because of memory implications. Key must be between 128 and 256 bits long.
Public methodStatic memberEnsureEnd
Ensures that the string ends with a specific string.
Public methodStatic memberEnsureStart
Ensures that the string starts with a specific string.
Public methodStatic memberFastConcat
Concatanates all strings in a single string.
Public methodStatic memberFindParameters

Gets all parameter names using {PARAM} format.

Example : "Move workflow {title} to state {state}." will return title and state.

Public methodStatic memberFirstLetterToLower
Converts the first letter of this string to lowercase.
Public methodStatic memberFirstLetterToUpper
Converts the first letter of this string to uppercase.
Public methodStatic memberGenerate
Creates a new string equal to a text repeated [number] times.
Public methodStatic memberGetAllIndexes
Finds all occurences of a text inside another and return corresponding indexes.
Public methodStatic memberGetBoolean
Tries to convert a text to Boolean. If not converted, will return false.
Public methodStatic memberGetBytes
Converts a string to an array of bytes.

Note : This method uses System.Buffer.BlockCopy.

Public methodStatic memberGetCronDay
Gets the day formatted text : uppercased three first letters.
Public methodStatic memberGetDate
Tries to convert a text to DateTime. If not converted, will return DateTime.MinValue.
Public methodStatic memberGetDateTimeOffset(String)
Tries to convert a text to DateTimeOffset. If not converted, will return DateTimeOffset.MinValue.
Public methodStatic memberGetDateTimeOffset(String, CultureInfo)
Tries to convert a text to DateTimeOffset. If not converted, will return DateTimeOffset.MinValue.
Public methodStatic memberGetDateTimeOffset(String, String, CultureInfo)
Tries to convert a text to DateTimeOffset using a specific format.

If not converted, will return DateTimeOffset.MinValue.

Public methodStatic memberGetDecimal(String)
Tries to convert a text to decimal. If not converted, will return 0.
Public methodStatic memberGetDecimal(String, CultureInfo)
Tries to convert a text to decimal using the given culture. If not converted, will return 0.
Public methodStatic memberGetDouble(String)
Tries to convert a text to double. If not converted, will return 0.
Public methodStatic memberGetDouble(String, CultureInfo)
Tries to convert a text to double using the given culture. If not converted, will return 0.
Public methodStatic memberGetFloat(String)
Tries to convert a text to float. If not converted, will return 0.
Public methodStatic memberGetFloat(String, CultureInfo)
Tries to convert a text to float using the given culture. If not converted, will return 0.
Public methodStatic memberGetGuid
Tries to convert a text to Guid. If not converted, will return Guid.Empty.
Public methodStatic memberGetHash
Gets a hash for the specified string.
Public methodStatic memberGetHashString
Gets a hash for the specified string.
Public methodStatic memberGetInt
Tries to convert a text to int. If not converted, will return 0.
Public methodStatic memberGetLong
Tries to convert a text to long. If not converted, will return 0.
Public methodStatic memberGetString
Converts an array of bytes to a string.

Note : This method uses System.Buffer.BlockCopy.

Public methodStatic memberGetStringWithMissingCR
If this string does not contain carrage return \r, xill replace all new line \n occurences by \r\n.
Public methodStatic memberHtmlAttributeEncode
Equivalent to HttpUtility.HtmlAttributeEncode()
Public methodStatic memberHtmlEncode
Equivalent to HttpUtility.HtmlEncode()
Public methodStatic memberIEquals
Checks if two strings are equal, ignoring case.
Public methodStatic memberInsert
Inserts multiple strings into the builder instance at the specified character position.
Public methodStatic memberInsertFormat
Inserts a single (formatted) string into the builder instance at the specified character position.
Public methodStatic memberIsNotNullOrEmpty
Checks if a string is NOT null or empty. Same behavior as !String.IsNullOrEmpty(s) method.
Public methodStatic memberIsNullOrEmpty
Checks if a string is null or empty. Same behavior as String.IsNullOrEmpty(s) method.
Public methodStatic memberLimitChars
Limits the length of this string to the given limit. Will not throw if it was not necessary.
Public methodStatic memberNotEmptyOr
Returns original text if not null or empty, otherwise return alternative text sent in parameters.
Public methodStatic memberNumberOfOccurences(String, Char)

Returns the number of occurences of a text inside another text.

Faster than other overload. Use this method if the search text is only a char.

Public methodStatic memberNumberOfOccurences(String, String)
Returns the number of occurences of a text inside another text.
Public methodStatic memberParseIndex
Returns an integer found between a char separator and the end of given string value.
Public methodStatic memberRemoveAccent
Replaces a, e, i, o, u, y letters with accent by the corresponding character without accent.
Public methodStatic memberRemoveBrackets
Removes the characters '[' and ']' from this string.
Public methodStatic memberRemoveDiacritics

Diacritic explantion from Wikipedia.

Some diacritical marks, such as the grave and acute, but not the cedilla, are often called accents.

Diacritical marks may appear above or below a letter, or in some other position such as within the letter or between two letters.

Public methodStatic memberRemoveStrings
Removes all occurences of given texts.
Public methodStatic memberReplace
Replaces all occurrences of a string by another string in this string with the possibility to ignore case.
Public methodStatic memberSerializeJson(Object)
Serializes an object using a DataContractJsonSerializer.
Public methodStatic memberSerializeJson(Object, ListType)
Serializes an object using a DataContractJsonSerializer.
Public methodStatic memberSerializeJson(Object, DataContractJsonSerializerSettings)
Serializes an object using a DataContractJsonSerializer.
Public methodStatic memberSmartSplit(String, ListString)
Splits a string into multiple parts using a list of separators.
Public methodStatic memberSmartSplit(String, String)
Splits a string into multiple parts using a given separator.
Public methodStatic memberSplitToPair
Splits a string into a apair of strings.
Public methodStatic memberSplitWords
Tokenizes the specified string. (words are splitted before every uppercase letter)
Public methodStatic memberStringToListT
Deserializes a serialized List.
Public methodStatic memberToCamelCase
Converts a text to camel case. E.g. "hello world" becomes "helloWorld".
Public methodStatic memberToKebabCase
Converts a text to kebab case. E.g. "HelloWorld" becomes "-hello-world".
Public methodStatic memberToLower
Converts this string to lowercase and remove accents if specified.
Public methodStatic memberToPascalCase
Converts a text to pascal case. E.g. "hello world" becomes "HelloWorld".
Public methodStatic memberToSentenceCase
Converts a text to a displayable text. E.g. "HelloWorld" becomes "Hello world".
Public methodStatic memberToSnakeCase
Converts a text to snake case. E.g. "HelloWorld" becomes "hello-world".
Public methodStatic memberToTitleCase
Converts a text to a displayable text. E.g. "HelloWorld" becomes "Hello World".
Public methodStatic memberTrimEnd
Removes all occurences of a string at the end of this string.
Public methodStatic memberTrimStart
Removes all occurences of a string at the begining of this string.
Public methodStatic memberTryConvertToEnumT(String)
Tries to obtain an enum value from a matching text.
Public methodStatic memberTryConvertToEnumT(String, Boolean)
Tries to obtain an enum value from a matching text.
Public methodStatic memberUnTrim(String, Int32)
Extends the string to the specified size using spaces.
Public methodStatic memberUnTrim(String, Int32, String)
Extends the string to the specified size using the given text.
Public methodStatic memberUrlTotalEncode
Encodes url in UTF8 format. Same behavior as HttpUtility.UrlEncode method.
Top
See Also