Created
August 9, 2019 09:02
-
-
Save vdovinanton/647c9a27b79d29dca84689fa3cdfa6b7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class CopyPropertiesHelper | |
{ | |
public static void CopyPropertiesTo<T>(this T from, T to) | |
{ | |
var fields = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance); | |
foreach (var field in fields) | |
{ | |
var value = field.GetValue(from); | |
field.SetValue(to, value); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment