Feedback

Wert in ein property schreiben

Sprache: VB

Den Wert einer property eines beliebigen Objects ändern.

        Public Shared Sub SetPropertyValue(ByVal obj As Object, ByVal sProperty As String, ByVal oValue As Object)
            Dim oParam() As Object = New Object
            oParam(0) = oValue
            obj.GetType().InvokeMember(sProperty, BindingFlags.SetProperty, Nothing, obj, oParam)
        End Sub

        Public Shared Sub SetPropertyValue(ByVal obj As Object, ByVal sProperty As String, ByVal oValue As Object)
            Dim oParam() As Object = New Object
            oParam(0) = oValue
            obj.GetType().InvokeMember(sProperty, BindingFlags.SetProperty, Nothing, obj, oParam)
        End Sub