MSDN gives this example of a deep copy (http://msdn.microsoft.com/en-us/library/system.object.memberwiseclone.aspx)
public class Person
{
public int Age;
Other alternative as object extension is the next:
public static class ObjectExtension
{
public static T Copy(this T lObjSource)
{
T lObjCopy = (T)Activator.CreateInstance(typeof(T));
foreach (PropertyInfo lObjCopyProperty in lObjCopy.GetType().GetProperties())
{
lObjCopyProperty.SetValue
(
lObjCopy,
lObjSource.GetType().GetProperties().Where(x => x.Name == lObjCopyProperty.Name).FirstOrDefault().GetValue(lObjSource)
);
}
return lObjCopy;
}
}
For use:
User lObjUserCopy = lObjUser.Copy();