public object Clone() { var otherEmail = new Email(); this.SetPropertyValues(otherEmail); return otherEmail; }
private void SetPropertyValues(Email otherEmail) { var propertyInfo = this.GetType().GetProperties().Where(p => p.CanWrite && (p.PropertyType.IsValueType || p.PropertyType.IsEnum || p.PropertyType.Equals(typeof(System.String)))); foreach (PropertyInfo property in propertyInfo) { if (property.CanWrite) { property.SetValue(otherEmail, property.GetValue(this, null), null); } } }