⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 item.cs

📁 详细介绍中小企业的网站编程,附有详细的注释,对需要制作网站的朋友有很大的帮助,有需要的朋友可下载,
💻 CS
字号:
using System;
///<summary>
//业务对象,表示产品。
///</summary>
public class Item
{
    //----------------------------------------------
    //私有字段区,定义属性内部使用的字段
    //----------------------------------------------
    private string  _id;            
    private string _title;          
    private bool    _visible;       
    private string  _description;   
    private double  _price;         
    private bool    _inStock;       
    private string  _imageUrl;      
    private string  _imageAltText;  
    //构造函数,为实体对象指定初始参数
    public Item(string id,
                bool visible,
                string title)
    {
        if (String.IsNullOrEmpty(id)) throw new ArgumentException(Messages.ItemIdUndefined);
        if (String.IsNullOrEmpty(title)) throw new ArgumentException(Messages.ItemTitleUndefined);
        _id = id;
        _visible = visible;
        _title = title;

    }
    //----------------------------------------------
    //属性定义区,为不同的实体属性定义访问方法。
    //----------------------------------------------   
    //主键ID
    public string Id
    {
        get { return String.IsNullOrEmpty(_id) ? String.Empty : _id; }
    }
    //产品是否可见
    public bool Visible
    {
        get { return _visible; }
        set { _visible = value; }
    }
    //产品标题
    public string Title
    {
        get { return String.IsNullOrEmpty(_title) ? String.Empty : _title; }
        set 
        {    if (String.IsNullOrEmpty(value))
            throw new InvalidOperationException(Messages.ItemTitleIsNull);
            _title = value; 
        }
    }
    //产品描述
    public string Description
    {
        get { return _description; }
        set { _description = value; }
    }
    //
    public double Price
    {
        get { return  _price; }
        set { _price = value; }
    }
    //产品价格
    public bool InStock
    {
        get { return _inStock; }
        set { _inStock = value; }
    }
    //产品图片链接
    public string ImageUrl
    {
        get { return String.IsNullOrEmpty(_imageUrl) ? String.Empty : _imageUrl; }
        set { _imageUrl = value; }
    }
    //产品图片显示交替文本。
    public string ImageAltText
    {
        get { return String.IsNullOrEmpty(_imageAltText) ? String.Empty : _imageAltText; }
        set { _imageAltText = value; }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -