mirror of
https://github.com/Stone-Red-Code/Stone_Red-C-Sharp-Utilities.git
synced 2026-09-09 09:55:59 +02:00
Created StringExtentions (markdown)
+132
@@ -0,0 +1,132 @@
|
|||||||
|
### Stone_Red_Utilities.StringExtentions
|
||||||
|
|
||||||
|
#### Methods
|
||||||
|
|
||||||
|
* EqualsIgnoreCase
|
||||||
|
* Description: Determines whether this instance and another specified string object have the same value regardless of upper and lower case.
|
||||||
|
* Parameters: `this string str`, `string value`
|
||||||
|
* Example usage:
|
||||||
|
|
||||||
|
```cs
|
||||||
|
string str1 = "BIG";
|
||||||
|
string str2 = "big";
|
||||||
|
|
||||||
|
bool match = str1.EqualsIgnoreCase(str2);
|
||||||
|
|
||||||
|
Console.WriteLine(match);
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
* Output:
|
||||||
|
|
||||||
|
```text
|
||||||
|
True
|
||||||
|
```
|
||||||
|
|
||||||
|
* EqualsIgnoreSpaces
|
||||||
|
* Description: Determines whether this instance and another specified string object have the same value regardless of spaces.
|
||||||
|
* Parameters: `this string str`, `string value`
|
||||||
|
* Example usage:
|
||||||
|
|
||||||
|
```cs
|
||||||
|
string str1 = "space";
|
||||||
|
string str2 = " s p a c e ";
|
||||||
|
|
||||||
|
bool match = str1.EqualsIgnoreSpaces(str2);
|
||||||
|
|
||||||
|
Console.WriteLine(match);
|
||||||
|
```
|
||||||
|
|
||||||
|
* Output:
|
||||||
|
|
||||||
|
```text
|
||||||
|
True
|
||||||
|
```
|
||||||
|
|
||||||
|
* EqualsIgnoreSpacesAndCase
|
||||||
|
* Description: Determines whether this instance and another specified string object have the same value regardless of upper and lower case and spaces.
|
||||||
|
* Parameters: `this string str`, `string value`
|
||||||
|
* Example usage:
|
||||||
|
|
||||||
|
```cs
|
||||||
|
string str1 = "BIG space";
|
||||||
|
string str2 = "big s p a c e ";
|
||||||
|
|
||||||
|
bool match = str1.EqualsIgnoreSpacesAndCase(str2);
|
||||||
|
|
||||||
|
Console.WriteLine(match);
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
* Output:
|
||||||
|
|
||||||
|
```text
|
||||||
|
True
|
||||||
|
```
|
||||||
|
|
||||||
|
* ToFileName
|
||||||
|
* Description: Determines whether this instance and another specified string object have the same value regardless of upper and lower case and spaces.
|
||||||
|
* Parameters: `this string str`, `string value`
|
||||||
|
* Example usage:
|
||||||
|
|
||||||
|
```cs
|
||||||
|
string str = "*n*/ /äme";
|
||||||
|
string fileName = str.ToFileName();
|
||||||
|
Console.WriteLine(fileName);
|
||||||
|
```
|
||||||
|
|
||||||
|
* Output:
|
||||||
|
|
||||||
|
```text
|
||||||
|
name
|
||||||
|
```
|
||||||
|
|
||||||
|
* ToPath
|
||||||
|
* Description: Determines whether this instance and another specified string object have the same value regardless of upper and lower case and spaces.
|
||||||
|
* Parameters: `this string str`, `string value`
|
||||||
|
* Example usage:
|
||||||
|
|
||||||
|
```cs
|
||||||
|
string str = "C://goöd /päth";
|
||||||
|
string fileName = str.ToPath();
|
||||||
|
Console.WriteLine(fileName);
|
||||||
|
```
|
||||||
|
|
||||||
|
* Output:
|
||||||
|
|
||||||
|
```text
|
||||||
|
C://good/path
|
||||||
|
```
|
||||||
|
|
||||||
|
* RemoveWhitespaces
|
||||||
|
* Description: Revoves all whitespaces from the specified string
|
||||||
|
* Parameters: `this string str`
|
||||||
|
* Example usage:
|
||||||
|
|
||||||
|
```cs
|
||||||
|
string str = "a b c";
|
||||||
|
string result = str.RemoveWhitespaces();
|
||||||
|
Console.WriteLine(result);
|
||||||
|
```
|
||||||
|
|
||||||
|
* Output:
|
||||||
|
|
||||||
|
```text
|
||||||
|
abc
|
||||||
|
```
|
||||||
|
|
||||||
|
* Reverse
|
||||||
|
* Description: Reverses the specified string
|
||||||
|
* Parameters: `this string str`
|
||||||
|
* Example usage:
|
||||||
|
|
||||||
|
```cs
|
||||||
|
string str = "em esrever";
|
||||||
|
Console.WriteLine(str.Reverse());
|
||||||
|
```
|
||||||
|
|
||||||
|
* Output:
|
||||||
|
|
||||||
|
```text
|
||||||
|
reverse me
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user