Provides an extension method on object to attempt to convert to any other type supported by any existing (or located) converters. If you need a special conversion to happen then implement IConverter<T1, T2> to convert between T1 and T2. Common .net type conversion from strings is already supported (based on culture-invariant conversions, eg "1.23" -> 1.23M)
More...
|
static bool | TryConvertTo< T > (this object input, out T converted) |
| Attempts to convert the object being operated on to the required type.
|
static bool | TryConvertTo (this object input, Type desiredType, out object converted) |
| Attempts to convert the object being operated on to the required type.
|
Provides an extension method on object to attempt to convert to any other type supported by any existing (or located) converters. If you need a special conversion to happen then implement IConverter<T1, T2> to convert between T1 and T2. Common .net type conversion from strings is already supported (based on culture-invariant conversions, eg "1.23" -> 1.23M)
◆ TryConvertTo()
bool PeanutButter.DuckTyping.Extensions.ConversionExtensions.TryConvertTo |
( |
this object | input, |
|
|
Type | desiredType, |
|
|
out object | converted ) |
|
static |
Attempts to convert the object being operated on to the required type.
- null always returns false
- attempting to convert to the same type returns the original object
- Parameters
-
input | |
desiredType | |
converted | |
- Returns
◆ TryConvertTo< T >()
Attempts to convert the object being operated on to the required type.
- null always returns false
- attempting to convert to the same type returns the original object
- Parameters
-
- Template Parameters
-
- Returns
The documentation for this class was generated from the following file:
- source/Utils/PeanutButter.DuckTyping/Extensions/ConversionExtensions.cs