Class StringExtensions
Represents various extension methods for type
Namespace: DotNext
Assembly: DotNext.dll
Syntax
public static class StringExtensions : object
Methods
| Improve this Doc View SourceGetRawData(String)
Gets managed pointer to the first character in the string.
Declaration
public static char GetRawData(this string str)
Parameters
| Type | Name | Description |
|---|---|---|
| String | str | The string data. |
Returns
| Type | Description |
|---|---|
| Char | The managed pointer to the first character in the string. |
IfNullOrEmpty(String, String)
Returns alternative string if first string argument is null or empty.
Declaration
public static string IfNullOrEmpty(this string str, string alt)
Parameters
| Type | Name | Description |
|---|---|---|
| String | str | A string to check. |
| String | alt | Alternative string to be returned if original string is null or empty. |
Returns
| Type | Description |
|---|---|
| String | Original or alternative string. |
Examples
This method is equivalent to
var result = string.IsNullOrEmpty(str) ? alt : str;
|
Improve this Doc
View Source
IsEqualIgnoreCase(String, String)
Compares two string using
Declaration
public static bool IsEqualIgnoreCase(this string strA, string strB)
Parameters
| Type | Name | Description |
|---|---|---|
| String | strA | String A. Can be null. |
| String | strB | String B. Can be null. |
Returns
| Type | Description |
|---|---|
| Boolean | true, if the first string is equal to the second string; otherwise, false. |
Reverse(String)
Reverse string characters.
Declaration
public static string Reverse(this string str)
Parameters
| Type | Name | Description |
|---|---|---|
| String | str | The string to reverse. |
Returns
| Type | Description |
|---|---|
| String | The string in inverse order of characters. |
Split(String, Int32)
Split a string into several substrings, each has a length not greater the specified one.
Declaration
public static ChunkSequence<char> Split(this string str, int chunkSize)
Parameters
| Type | Name | Description |
|---|---|---|
| String | str | The string to split. |
| Int32 | chunkSize | The maximum length of the substring in the sequence. |
Returns
| Type | Description |
|---|---|
| ChunkSequence<Char> | The sequence of substrings. |
TrimLength(String, Int32)
Trims the source string to specified length if it exceeds it.
If source string is less that maxLength then the source string returned.
Declaration
public static string TrimLength(this string str, int maxLength)
Parameters
| Type | Name | Description |
|---|---|---|
| String | str | Source string. |
| Int32 | maxLength | Maximum length. |
Returns
| Type | Description |
|---|---|
| String | Trimmed string value. |