Question : C# Class

public class ProductList
{
  private string _ItemID;
  private string _Descr;
  private double _OnHandQty;

  //Paramaterized constructor
  public ProductList(string ItemID, string Descr, double OnHandQty)
  {
    _ItemID = ItemID;
    _Descr = Descr;
    _OnHandQty = OnHandQty;
  }

  //Default constructor
  public ProductList()
  {
  }

  public string ItemID
  {
    get { return _ItemID; }
    set { _ItemID = value; }
  }

  public string Descr
  {
    get { return _Descr; }
    set { _Descr = value; }
  }


  public double OnHandQty
  {
    get { return _OnHandQty; }
    set { _OnHandQty = value; }
  }
}

In above, how can I rewrite whole class to use short syntax like
public string ItemID { get; set; }

Thanks,
Ashok

Answer : C# Class

this would be how it works...
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
public class ProductList
{
  //Paramaterized constructor
  public ProductList(string ItemID, string Descr, double OnHandQty)
  {
    this.ItemID = ItemID;
    this.Descr = Descr;
    this.OnHandQty = OnHandQty;
  }
 
  //Default constructor
  public ProductList()
  {
  }
 
  public string ItemID
  {
    get;
    set;
  }
 
  public string Descr
  {
    get;
    set;
  }
 
 
  public double OnHandQty
  {
    get;
    set;
  }
}
Random Solutions  
 
programming4us programming4us