Tries to convert an Object specified in the obj parameter to the desired TTarget.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
Namespace: KGySoft.CoreLibraries
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 5.0.0
Syntax
public static bool TryConvert<TTarget>( this Object obj, CultureInfo culture, out TTarget value )
Parameters
- obj
- Type: SystemObject
The object to convert. - culture
- Type: System.GlobalizationCultureInfo
The culture to use for the conversion. If , then the InvariantCulture will be used. - value
- Type: TTarget
When this method returns with result, then this parameter contains the result of the conversion.
Type Parameters
- TTarget
- The desired type of the returned value.
Return Value
Type: Boolean, if obj could be converted to TTarget, which is returned in the value parameter; otherwise, .
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type Object. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).Remarks
New conversions can be registered by the RegisterConversion Type extension methods.
![]() |
---|
The registered conversions are tried to be used for intermediate conversion steps if possible. For example, if a conversion is registered from Int64 to IntPtr, then conversions from other convertible types become automatically available using the Int64 type as an intermediate conversion step. |
See Also