Example: I am working with an API that has definitions for various objects with many properties.
This object has about 40 properties, and I'd like to set them all.
Is there a way to auto-generate the following code from an object?
contact.AddressId = null;
contact.Anniversary = null;
contact.AssistantId = null;
contact.BirthDay = null;
contact.Children = null;
contact.CompanyAddressInfo = null;
contact.CompanyIdentifier = null;
contact.DisablePortalLogin = null;
contact.Email = null;
contact.Emails = null;
contact.ExtensionData = null;
contact.Fax = null;
contact.Faxes = null;
contact.FaxExt = null;
contact.FirstName = null;
contact.Gender = null;
contact.Id = null;
contact.Inactive = null;
contact.LastName = null;
contact.LastUpdated = null;
contact.ManagerId = null;
contact.Married = null;
contact.NickName = null;
contact.PersonalAddress = null;
contact.PersonalAddressFlag = null;
contact.Phone = null;
contact.PhoneExt = null;
contact.Phones = null;
contact.PortalPassword = null;
contact.PortalSecurityLevel = null;
contact.Relationship = null;
contact.School = null;
contact.SID = null;
contact.SignificantOther = null;
contact.SiteName = null;
contact.Title = null;
contact.Type = null;
contact.UnsubscribeFlag = null;
contact.UpdatedBy = null;
The purpose is for visualization and for me to see what I am and am not setting in my code.
Edited to be more specific.
Try this
static void Main(string[] args)
{
Contact obj = new Contact();
var props = obj.GetType().GetProperties();
foreach (var p in props)
Console.WriteLine("contact.{0}= null;", p.Name);
Thread.Sleep(1000);
}
Then copy paste the console screen or write it to a file instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With