CapyKit/Docs/api/CapyKit.Extensions.StringExtensions.md

88 lines
3.3 KiB
Markdown

# <a id="CapyKit_Extensions_StringExtensions"></a> Class StringExtensions
Namespace: [CapyKit.Extensions](CapyKit.Extensions.md)
Assembly: CapyKit.dll
Provides static extentions methods for providing additional functionality for <xref href="System.String" data-throw-if-not-resolved="false"></xref> types.
```csharp
public static class StringExtensions
```
#### Inheritance
[object](https://learn.microsoft.com/dotnet/api/system.object) ←
[StringExtensions](CapyKit.Extensions.StringExtensions.md)
#### Inherited Members
[object.Equals\(object?\)](https://learn.microsoft.com/dotnet/api/system.object.equals\#system\-object\-equals\(system\-object\)),
[object.Equals\(object?, object?\)](https://learn.microsoft.com/dotnet/api/system.object.equals\#system\-object\-equals\(system\-object\-system\-object\)),
[object.GetHashCode\(\)](https://learn.microsoft.com/dotnet/api/system.object.gethashcode),
[object.GetType\(\)](https://learn.microsoft.com/dotnet/api/system.object.gettype),
[object.MemberwiseClone\(\)](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone),
[object.ReferenceEquals\(object?, object?\)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals),
[object.ToString\(\)](https://learn.microsoft.com/dotnet/api/system.object.tostring)
#### Extension Methods
[ObjectExtensions.UpdateProperties\(object, object\)](CapyKit.Extensions.ObjectExtensions.md\#CapyKit\_Extensions\_ObjectExtensions\_UpdateProperties\_System\_Object\_System\_Object\_)
## Methods
### <a id="CapyKit_Extensions_StringExtensions_IfNullOrEmpty_System_String_System_String_"></a> IfNullOrEmpty\(string, string\)
Replaces a null or empty string with a specified replacement string.
```csharp
public static string IfNullOrEmpty(this string value, string replacement)
```
#### Parameters
`value` [string](https://learn.microsoft.com/dotnet/api/system.string)
The original string.
`replacement` [string](https://learn.microsoft.com/dotnet/api/system.string)
The replacement string.
#### Returns
[string](https://learn.microsoft.com/dotnet/api/system.string)
The original string if not null or empty, otherwise the replacement string.
#### See Also
[string](https://learn.microsoft.com/dotnet/api/system.string).[IsNullOrEmpty](https://learn.microsoft.com/dotnet/api/system.string.isnullorempty)\([string](https://learn.microsoft.com/dotnet/api/system.string)?\)
### <a id="CapyKit_Extensions_StringExtensions_IfNullOrWhiteSpace_System_String_System_String_"></a> IfNullOrWhiteSpace\(string, string\)
Replaces a null or whitespace string with a specified replacement string.
```csharp
public static string IfNullOrWhiteSpace(this string value, string replacement)
```
#### Parameters
`value` [string](https://learn.microsoft.com/dotnet/api/system.string)
The original string.
`replacement` [string](https://learn.microsoft.com/dotnet/api/system.string)
The replacement string.
#### Returns
[string](https://learn.microsoft.com/dotnet/api/system.string)
The original string if not null or whitespace, otherwise the replacement string.
#### See Also
[string](https://learn.microsoft.com/dotnet/api/system.string).[IsNullOrWhiteSpace](https://learn.microsoft.com/dotnet/api/system.string.isnullorwhitespace)\([string](https://learn.microsoft.com/dotnet/api/system.string)?\)