日期:2014-05-18  浏览次数:21066 次

.net 当 实体类de构造函数 参数个数相同和类型相同,怎么解决?急急急
.net 当我的实体类 构造函数 个数相同,类型相同,但是我传入的参数是不同的,我知道这个情况是不能让构造函数重载的。那么我应该怎么实现这个方法呢?

代码如下

外借表实体类
C# code

/* 
 *  作者: 
 *  创建时间:2012/3/19 18:32:11
 *  类说明:借出表实体类
 */
/// <summary>
/// 借出表实体类
/// </summary>
public class LendInfo
{
    private string lendId;
    /// <summary>
    /// 借出id
    /// </summary>
    public string LendId
    {
        get { return lendId; }
        set { lendId = value; }
    }

    private string deviceId;
    /// <summary>
    /// 设备id
    /// </summary>
    public string DeviceId
    {
        get { return deviceId; }
        set { deviceId = value; }
    }

    private string lendPreson;
    /// <summary>
    /// 借出人
    /// </summary>
    public string LendPreson
    {
        get { return lendPreson; }
        set { lendPreson = value; }
    }

    private string lendPresonPhone;
    /// <summary>
    /// 借出人联系电话
    /// </summary>
    public string LendPresonPhone
    {
        get { return lendPresonPhone; }
        set { lendPresonPhone = value; }
    }

    private string lendDate;
    /// <summary>
    /// 借出日期
    /// </summary>
    public string LendDate
    {
        get { return lendDate; }
        set { lendDate = value; }
    }

    private string lendDays;
    /// <summary>
    /// 借出天数
    /// </summary>
    public string LendDays
    {
        get { return lendDays; }
        set { lendDays = value; }
    }

    private string returnDate;
    /// <summary>
    /// 归还日期
    /// </summary>
    public string ReturnDate
    {
        get { return returnDate; }
        set { returnDate = value; }
    }

    private string isReturn;
    /// <summary>
    /// 是否归还
    /// </summary>
    public string IsReturn
    {
        get { return isReturn; }
        set { isReturn = value; }
    }

    private string state;
    /// <summary>
    /// 审核状态
    /// </summary>
    public string State
    {
        get { return state; }
        set { state = value; }
    }

    private string applyPreson;
    public string ApplyPreson
    {
        get { return applyPreson; }
        set { applyPreson = value; }

    }

    private string checkDate;
    public string CheckDate
    {
        get { return checkDate; }
        set { checkDate = value; }
    }


    private string checkPreson;
    public string CheckPreson
    {
        get { return checkPreson; }
        set { checkPreson = value; }

    }

    public LendInfo() { }

    //第一个构造方法
    public LendInfo(string lendId, string deviceId, string lendPreson, string lendPresonPhone,
        string lendDate, string lendDays, string returnDate, string isReturn, string state, string applyPreson,
        string checkDate, string checkPreson)
    {
        this.lendId = lendId;
        this.deviceId = deviceId;
        this.lendPreson = lendPreson;
        this.lendPresonPhone = lendPresonPhone;
        this.lendDate = lendDate;
        this.lendDays = lendDays;
        this.returnDate = returnDate;
        this.isReturn = isReturn;
        this.state = state;
        this.applyPreson = applyPreson;
        this.checkDate = checkDate;
        this.checkPreson = checkPreson;
    }


        /// <summary>
    /// 申请添加信息 (第二个构造方法)
    /// </summary>
    /// <param name="deviceId"></param>
    /// <param name="lendPreson"></param>
    /// <param name="lendPresonPhone"></param>
    /// <param name="lendDate"></param>
    /// <param name="lendDays"></param>
    /// <param name="applyPreson"></param>
    public LendInfo(string deviceId, string lendPreson, string lendPresonPhone,
        string lendDate, string lendD