c#中我看到一个类的构造函数是这样写的
public SqlStruct(string p_strSql) : this(p_strSql, CommandType.Text, null){}
这是什么用法呢?索引器吗?产生什么效用呢?求解!!!

解决方案 »

  1.   

    public SqlStruct(string p_strSql) : this(p_strSql, CommandType.Text, null){}
    //就是将p_strSql, CommandType.Text, null 传给他的基类的构造函数
      

  2.   

    public SqlStruct(string p_strSql) : this(p_strSql, CommandType.Text, null){}该类一定还有一个构造函数的声明为:
    public SqlStruct(string p_strSql,CommandType,...)
    第一句的语句的意思,即在执行该构造函数时先调用本类的另外一个构造函数,该构造函数的Signature(输入参数列表)和this后的描述一致。
    如果是base(...)则代表先调用基类的某个构造函数