Class GenericExtensions
Inheritance
System.Object
GenericExtensions
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Piksel.Helpers
Assembly: cs.temp.dll.dll
Syntax
public static class GenericExtensions
Methods
TryConvert<TSource, TResult>(TSource, Func<TSource, TResult>, out TResult)
Attempt to convert source
into result
using conversionFunction
Declaration
public static bool TryConvert<TSource, TResult>(this TSource source, Func<TSource, TResult> conversionFunction, out TResult result)
Parameters
Type | Name | Description |
---|---|---|
TSource | source | |
Func<TSource, TResult> | conversionFunction | |
TResult | result |
Returns
Type | Description |
---|---|
System.Boolean | Returns whether |
Type Parameters
Name | Description |
---|---|
TSource | Source type |
TResult | Result type |
Remarks
Types can usually be inferred by the body of conversionFunction
Examples
if (foo.TryConvert(b => b.ToString(), out string result)) { // use result }