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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top