Skip to content

Instantly share code, notes, and snippets.

View undrivendev's full-sized avatar
👋
Hey there!

Luca Dalla Valle undrivendev

👋
Hey there!
View GitHub Profile
/// <summary>
/// copies the properties with the same name and type from the objectFrom to the objectTo.
/// Beware, it uses reflection, so it can be slow for certain scenarios
/// </summary>
public static void CopyObjectPropertyValues(object objectFrom, object objectTo)
{
var propertiesFrom = objectFrom.GetType().GetProperties();
var propertiesTo = objectTo.GetType().GetProperties();
foreach (var propFrom in propertiesFrom)