我分配了两个字符串数组:
string[] SelectColumns = {},WhereColumns={};
它们都充满了数据项。例如 SelectColumns.length = 7,WhereColumns.Length=3;
当我去实现它们时,我遇到了一个异常:object reference not set to an instance of an object。我在下面使用它们:
for (int i = 0; i < SelectColumns.Length; i++)
{
DPS._SelectCol[i] = SelectColumns[i];
}
for (int i = 0; i < WhereColumns.Length; i++)
{
DPS._WhereCol[i] = WhereColumns[i];
}
这里DPS是一个类的对象,如下所示:
public class DefaultProfileSetting
{
private string Server;
public string _Server
{
get { return Server; }
set { Server = value; }
}
private string Authentication;
public string _Authentication
{
get { return Authentication; }
set { Authentication = value; }
}
private string Login;
public string _Login
{
get { return Login; }
set { Login = value; }
}
private string Pass;
public string _Pass
{
get { return Pass; }
set { Pass = value; }
}
private string DB;
public string _DB
{
get { return DB; }
set { DB = value; }
}
private string Table;
public string _Table
{
get { return Table; }
set { Table = value; }
}
private string[] SelectCol;
public string[] _SelectCol
{
get { return SelectCol; }
set { SelectCol = value; }
}
private string[] WhereCol;
public string[] _WhereCol
{
get { return WhereCol; }
set { WhereCol = value; }
}
}