Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class Class2
- Private newPropertyValue2 As String
- Public Property NewProperty2() As String
- Get
- Return newPropertyValue2
- End Get
- Set(ByVal value As String)
- newPropertyValue2 = value
- End Set
- End Property
- End Class
- Public Class ObjectCompare
- Private _OriginalObject As PropertyInfo()
- Public Property OriginalObject() As PropertyInfo()
- Get
- Return _OriginalObject
- End Get
- Set(ByVal value As PropertyInfo())
- _OriginalObject = value
- End Set
- End Property
- Public Sub CompareObjects()
- Dim property_value As Object
- For i As Integer = 0 To OriginalObject.Length - 1
- If OriginalObject(i).GetIndexParameters().Length = 0 Then
- Dim propInfo As PropertyInfo = OriginalObject(i)
- Try
- property_value = propInfo.GetValue(Me, Nothing)
- Catch ex As TargetException
- End Try
- End If
- Next
- End Sub
- End Class
- Dim test As New Class2
- test.NewProperty2 = "2"
- Dim go As New ObjectCompare
- Dim propInf As PropertyInfo()
- propInf = test.GetType.GetProperties()
- go.OriginalObject = propInf
- go.CompareObjects()
- Public Sub CompareObjects(ByVal It as Object)
- Dim property_value As Object
- For i As Integer = 0 To OriginalObject.Length - 1
- If OriginalObject(i).GetIndexParameters().Length = 0 Then
- Dim propInfo As PropertyInfo = OriginalObject(i)
- Try
- property_value = propInfo.GetValue(It, Nothing)
- Catch ex As TargetException
- End Try
- End If
- Next
- End Sub
- go.CompareObjects(test)
- Dim test As New Class2
- test.NewProperty2 = "2"
- Dim go As New ObjectCompare
- go.CompareObjects(test)
- Public Class Class2
- Private newPropertyValue2 As String
- Public Property NewProperty2() As String
- Get
- Return newPropertyValue2
- End Get
- Set(ByVal value As String)
- newPropertyValue2 = value
- End Set
- End Property
- End Class
- Public Class ObjectCompare
- Public Sub CompareObjects(ByVal MyType As Object)
- For Each Prop In MyType.GetType().GetProperties()
- Dim value = Prop.GetValue(MyType, Nothing)
- Console.WriteLine(value)
- Next
- Console.ReadLine()
- End Sub
- End Class
Add Comment
Please, Sign In to add comment