amir-aa
چهارشنبه 26 مرداد 1390, 18:10 عصر
سلام دوستان من اولین بارمه که با کلاس ها تو سی شارپ کار می کنم
من این کد رو نوشتم ولی روی _items ارور می ده.
namespace WebApplication1
{
[Serializable]
public class cartitem
{
private string _name;
private string _type;
private int _price;
private string _aks;
private int _id;
private int _total;
private int _tedad;
public void New()
{
}
public void New(string name, string type, int price, string aks, int id, int total, int tedad)
{
_id = id;
_name = name;
_price = price;
_type = type;
_aks = aks;
_total = total;
_tedad = tedad;
}
public int id
{
get
{
return _id;
}
set
{
_id = value;
}
}
//*************
public string name
{
get
{
return _name;
}
set
{
_name = value;
}
}
//***********
public int price
{
get
{
return _price;
}
set
{
_price = value;
}
}
//***********
public string type
{
get
{
return _type;
}
set
{
_type = value;
}
}
//**********
public int tedad
{
get
{
return _tedad;
}
set
{
_tedad = value;
}
}
//*********
public int total
{
get
{
return _tedad * _price;
}
}
}
//**************
[Serializable]
public class shoppingcard
{
private List<cartitem> _items;
public shoppingcard
{
if(this._items==null)
{
this._items=new List<cartitem>();
}
}
}
}
من این کد رو نوشتم ولی روی _items ارور می ده.
namespace WebApplication1
{
[Serializable]
public class cartitem
{
private string _name;
private string _type;
private int _price;
private string _aks;
private int _id;
private int _total;
private int _tedad;
public void New()
{
}
public void New(string name, string type, int price, string aks, int id, int total, int tedad)
{
_id = id;
_name = name;
_price = price;
_type = type;
_aks = aks;
_total = total;
_tedad = tedad;
}
public int id
{
get
{
return _id;
}
set
{
_id = value;
}
}
//*************
public string name
{
get
{
return _name;
}
set
{
_name = value;
}
}
//***********
public int price
{
get
{
return _price;
}
set
{
_price = value;
}
}
//***********
public string type
{
get
{
return _type;
}
set
{
_type = value;
}
}
//**********
public int tedad
{
get
{
return _tedad;
}
set
{
_tedad = value;
}
}
//*********
public int total
{
get
{
return _tedad * _price;
}
}
}
//**************
[Serializable]
public class shoppingcard
{
private List<cartitem> _items;
public shoppingcard
{
if(this._items==null)
{
this._items=new List<cartitem>();
}
}
}
}