So I have two "documents" that both have allot of properties. One document is an instance of a document that has been filled out. I need to check if there is a 'Value" in the property (since they are mainly nullable int?) and if so assign the value of the current property to the property of the other document.
Example
if (documentA.FirstProperty.HasValue)
{
documentB.FirstProperty = documentA.FirstProperty
}
But is there a way to make this clearner? I thought maybe I could create a list of the document type and using a foreach loop and check if the current property has a value and if so assign it to the new document.
With having already acquired an instance of a document called oldDocument
Example:
List<oldDocument> listOfProperties = new List<oldDocument>();
foreach (var property in listOfProperties)
{
if (property.HasValue)
{
documentB.property = documentA.property;
}
}
Where the variable "property" in the foreach loop would represent the name of the property?