Casting : example in VB.NET

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Vic

    #1

    Casting : example in VB.NET

    Hi,

    in VB.NET there is the following code:

    Friend htProvidedPrope rties As New Hashtable()

    Private Class TextboxValidato rProvidedProper ties
    Public DataType As DataTypeConstan ts
    Public RegularExpressi on As String = String.Empty
    End Class

    'casting 1
    Dim ProvidedPropert ies As
    TextboxValidato rProvidedProper ties = DirectCast
    (htProvidedProp erties(ctrl),
    TextboxValidato rProvidedProper ties)

    'Casting2
    Return DirectCast(htPr ovidedPropertie s(ctrl),
    TextboxValidato rProvidedProper ties).DataType


    How can I do the casting (1 and 2) in C#?
    I tried Convert.ChangeT ype(htProvidedP roperties(ctrl) ,
    TextboxValidato rProvidedProper ties);
    But it don't work (gives errors).

    Thanks in advance
    Vic

  • Mattias Sjögren

    #2
    Re: Casting : example in VB.NET

    Vic,
    [color=blue]
    >How can I do the casting (1 and 2) in C#?[/color]

    ((TextboxValida torProvidedProp erties)ctrl)



    Mattias

    --
    Mattias Sjögren [MVP] mattias @ mvps.org

    Please reply only to the newsgroup.

    Comment

    Working...