Torna al Thread

Public Function SetProperty(ByVal obj As Object, ByVal propertyName As String, ByVal val As Object) As Boolean Try Dim properties() As String = propertyName.Split("|") Dim pi As System.Reflection.PropertyInfo = Nothing For Each p As String In properties pi = obj.GetType().GetProperty(p) If Not pi Is Nothing Then Exit For Next If pi Is Nothing Then Return False val = Convert.ChangeType(val, pi.PropertyType) pi.SetValue(obj, val, Nothing) Return True Catch Return False End Try End Function
Copyright © dotNetHell.it 2002-2025
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5