Return to Snippet

Revision: 13625
at April 29, 2009 14:23 by delm


Initial Code
Public Sub Asimilar(of T)(ByVal target as T, ByVal source As T)
  Dim propiedades As PropertyInfo()
  Dim type As Type = target.GetType()
  propiedades = type.GetProperties()

  For Each pi As PropertyInfo In propiedades
    If pi.CanWrite Then pi.SetValue(target, pi.GetValue(source, Nothing), Nothing)
  Next
End Sub

Initial URL

                                

Initial Description
Dado un objeto original, este método copia los valores de ese objeto en un segundo objeto de la misma clase, utilizando reflection.

Initial Title
Asimilar valores de un objeto de la misma clase

Initial Tags
copy

Initial Language
VB.NET