对不起标题,但我不知道其他提问方式。
为便于解释而编辑
public Dictionary<string, string>[] getValuesDB(DataSet ds)
{
Dictionary<string, string>[] info;
Dictionary<string, string>[] temp = new Dictionary<string, string>[ds.Tables[0].Rows.Count];
Dictionary<string, string> d;
string ciclo = "CICLO 02";
try
{
for (int c = 0; c < ds.Tables[0].Rows.Count; c++)
{
d = new Dictionary<string, string>();
OracleConn ora = OracleConn.getInstancia();
DataSet oraDs = ora.getClientByCycle(ds.Tables[0].Columns["IDCliente"].Table.Rows[c].ItemArray[1].ToString(), ciclo);
if (oraDs.Tables[0].Rows.Count > 0)
{
oraDs.Tables[0].Columns[5].Table.Rows[0].ToString();
d.Add("DomID", ds.Tables[0].Columns["DomID"].Table.Rows[c].ItemArray[0].ToString());
d.Add("ClientID", ds.Tables[0].Columns["ClientID"].Table.Rows[c].ItemArray[1].ToString());
d.Add("AccountType", ds.Tables[0].Columns["AccountType"].Table.Rows[c].ItemArray[2].ToString());
temp[c] = d;
}
}
}
catch (Exception eo)
{
}
int count = 0;
for (int i = 0; i < temp.Length; i++)
{
if (temp[i] != null)
count++;
}
info = new Dictionary<string, string>[count];
return info;
现在我需要从“temp”中获取所有非空值并将其放入信息中 任何想法
请您参考如下方法:
试试这个
Dictionary<string, string> dictionaryWithoutNulls ;
dictionaryWithoutNulls = dictionaryWithNulls
.Where(d => d.Value != null)
.ToDictionary(s=>s.Key, s=>s.Value);
