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 KumarPosted May 25, 2015, 6:01 AM
Pankaj Kumar ChoudharyPosted May 25, 2015, 5:57 AM
Pankaj Kumar ChoudharyPosted May 25, 2015, 5:55 AM
{
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();
}
hadoop hadoopPosted May 25, 2015, 5:40 AM
Shubham KumarPosted May 25, 2015, 5:24 AM