jeudi 3 décembre 2015

how to know if a property from PropertInfo (reflection) Is an Array

i got a class like that :

<Serializable()> Public Class SACCVar


Private _Code_Produit As String
Private _Voie_Ana_Name(6) As String

Public Property Voie_Ana_Name(index As Integer) As String
    Get
        Return _Voie_Ana_Name(index)
    End Get
    Set(value As String)

        _Voie_Ana_Name(index) = value
    End Set
End Property
 Public Property Code_Produit As String
        Get
            Return _Code_Produit
        End Get
        Set(value As String)
             _Code_Produit = value
         End Set
    End Property
    End Class

then i want to loop through the class property using this :

dim saccdata as SACCVar
Dim VarType As Type = GetType(SACCVar)
Dim properties As PropertyInfo() = VarType.GetProperties()

 For Each proper As PropertyInfo In properties

    proper.GetValue(SaccData, {0})

 next

BUT with the getvalue if i want to get code_produit i have to set nothing in place of {0} because it's not an array.

So my question is how do i detect that proper is an array or not?

Thank you





Aucun commentaire:

Enregistrer un commentaire