我有列表的方法是具有三项方如何访问数组列表?这样<strong>测试</strong>
public ArrayList converttolist(string commandText, CommandType commandType)
{
ArrayList Listlines = new ArrayList();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = commandText;
cmd.CommandType = commandType;
cmd.Connection = obj_con.getconection();
try
{
cmd.Connection.Open();
using (SqlDataReader sdr = cmd.ExecuteReader(CommandBehavior.CloseConnection))
{
testing ts = new testing();
var alldata = new state_testingCLS.testing();
while (sdr.Read())
{
ts.id_11 = Convert.ToInt64(sdr["id_11"]);
ts.countryid = Convert.ToInt64(sdr["countryid"]);
ts.state = Convert.ToString(sdr["state"]);
Listlines.Add((ts));
}
sdr.Close();
}
return Listlines;
}
catch (Exception ex)
{
throw ex;
}
finally
{
cmd.Connection.Close();
cmd.Dispose();
}
}
在listlines我要取的记录类,但我没有任何想法,这一个,请帮我在这一个
现在,如果我访问它
ArrayList aa= cls.getAll();
foreach (state_testingCLS.testing Txt in aa)
{
string aa1 = Txt.state.ToString();
}
相同的数据返回每次
检查更新@NitinVarpe –
我不知道如果我理解你的问题中取值,但要插入'alldata'但从来没有设置它的任何属性。你是否想要插入'ts'? ('Listlines.Add(ts)') –
对不起这是我的错误@ClaudioRedi –