Casting : example in VB.NET

  • Thread starter Thread starter Vic
  • Start date Start date
V

Vic

Hi,

in VB.NET there is the following code:

Friend htProvidedProperties As New Hashtable()

Private Class TextboxValidatorProvidedProperties
Public DataType As DataTypeConstants
Public RegularExpression As String = String.Empty
End Class

'casting 1
Dim ProvidedProperties As
TextboxValidatorProvidedProperties = DirectCast
(htProvidedProperties(ctrl),
TextboxValidatorProvidedProperties)

'Casting2
Return DirectCast(htProvidedProperties(ctrl),
TextboxValidatorProvidedProperties).DataType


How can I do the casting (1 and 2) in C#?
I tried Convert.ChangeType(htProvidedProperties(ctrl),
TextboxValidatorProvidedProperties);
But it don't work (gives errors).

Thanks in advance
Vic
 
Back
Top