如何在C#中将所有元素存储在数组中 [英] How Do I Store All Elements In Array In C#
问题描述
我想存储元素就像从数据库到数组变量的堆栈推送操作一样,我试过但它没有正确地存储数组中的元素。所以任何人都可以建议我如何在数组中存储元素我的代码是.. Hi,I want to store elements Like a stack push operation from database to in array variable ,I have tried But it doesn't store elements in array properly.So can anyone suggest me for how to store elements in array my code is.. 这篇关于如何在C#中将所有元素存储在数组中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
<前lang =cs> 受保护 void RelativeFamilyIDFrom( Double RelativeMemberID)
{
Double [] allFamily = new Double [ 10 跨度>];
Double id;
sSQL = SELECT AF_FamilyID FROM AllFamily;
sSQL = sSQL + WHERE AF_MemberID IN(' + RelativeMemberID + ');
DS = new DataSet();
da = new OdbcDataAdapter(sSQL,conn);
da.Fill(DS);
ArrayList list = new ArrayList();
if (DS.Tables.Count > 0 )
{
if (DS.Tables [ table]。Rows.Count > 0 )
{
for ( int i = 0 ; i < DS.Tables [ table]。Rows.Count; i ++)
{
allFamily [i] = Convert.ToDouble(DS.Tables [ table]。行[i] [ AF_FamilyID跨度>]的ToString());
list.Add(allFamily [i]);
}
}
}
}
如果RelativeMemberID = 81且匹配AF_FamilyID = 1和2,那么如何将这两个元素存储在数组中,如堆栈如果两个返回行,将两者都添加到数组列表中。
protected void RelativeFamilyIDFrom(Double RelativeMemberID)
{
Double[] allFamily = new Double[10];
Double id;
sSQL = "SELECT AF_FamilyID FROM AllFamily";
sSQL = sSQL + " WHERE AF_MemberID IN('" + RelativeMemberID + "')";
DS = new DataSet();
da = new OdbcDataAdapter(sSQL,conn);
da.Fill(DS);
ArrayList list = new ArrayList();
if (DS.Tables.Count > 0)
{
if (DS.Tables["table"].Rows.Count > 0)
{
for (int i = 0; i < DS.Tables["table"].Rows.Count; i++)
{
allFamily[i] = Convert.ToDouble( DS.Tables["table"].Rows[i]["AF_FamilyID"].ToString());
list.Add(allFamily[i]);
}
}
}
}
if RelativeMemberID=81 and matching AF_FamilyID = 1 and 2 ,then how can i store both these element in array like as a stackIf two rows are returned, add both to the array list.