ArcFM Engine Developer Guide
TryCast<T> Method


The type of the value to be returned.
The object to be cast.
The default value to be returned if the object to be cast is null or DBNull.
Trys to casts an object to the type of the given default value. If the object cannot be cast, the default value specified will be returned. If the object is convertable to the type of the default value, the explicit conversion will be performed.
Syntax
'Declaration
 
Public Shared Function TryCast(Of T)( _
   ByVal obj As Object, _
   ByVal defaultValue As T _
) As T
'Usage
 
Dim obj As Object
Dim defaultValue As T
Dim value As T
 
value = ProvidersHelper.TryCast(Of T)(obj, defaultValue)
public static T TryCast<T>( 
   object obj,
   T defaultValue
)

Parameters

obj
The object to be cast.
defaultValue
The default value to be returned if the object to be cast is null or DBNull.

Type Parameters

T
The type of the value to be returned.

Return Value

The value of the object cast to the type of the default value.
Exceptions
ExceptionDescription
System.InvalidCastExceptionThrown if the type of the object cannot be cast to the type of the default value.
Requirements

Target Platforms: Windows XP SP3 (32-bit and 64-bit), Windows 7 (32-bit and 64-bit)

Not all Operating Systems are supported on all products. Visit the ArcFM Solution Supported Versions page for full details.

See Also

Reference

ProvidersHelper Class
ProvidersHelper Members

 

 


Send Comment