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?

Shubham KumarRank #621 · 3.8K reputationPosted May 25, 2015, 1:24 AM EDT
hadoop hadoop142 reputationPosted May 25, 2015, 1:40 AM EDT
Pankaj Kumar ChoudharyRank #80 · 24.4K reputationPosted May 25, 2015, 1:55 AM EDT
{
string stm;
public string str
{
get
{
return stm;
}
set
{
stm = value ;
}
}
public dmr()
{
str = "na";
}
}
class Demo
{
static void Main(string[] args)
{
dmr dmo = new dmr();
Console.WriteLine(dmo.str);
Console.ReadLine();
}
Pankaj Kumar ChoudharyRank #80 · 24.4K reputationPosted May 25, 2015, 1:57 AM EDT
Shubham KumarRank #621 · 3.8K reputationPosted May 25, 2015, 2:01 AM EDT