hadoop hadoop

hadoop hadoop

  • NA
  • 159
  • 51.1k

set the default value of class property if it is null

May 25 2015 5:11 AM
I've a class. How to set default value of the class properties to "na" in case they are null.
public class PharmacyOrder
{
public class MedicineRecord
{
   // how to set default value "na" for these properties
   public string MedicineId { get; set; }
   public string MedicineName { get; set; }
   public string MedicineDealer { get; set; }
}
}
this MedicineRecord is called from another class.
public PharmacyOrder.MedicineRecord SetMedicineRecord()
{
   PharmacyOrder.MedicineRecord obj = new PharmacyOrder.MedicineRecord();
obj.MedicineId = // assigned values
   // for other properties too
}
how to set default value of the properties to "na" to assign default value when null is passed?

Answers (5)