如何在C#中将所有元素存储在数组中 [英] How Do I Store All Elements In Array In C#

查看:331
本文介绍了如何在C#中将所有元素存储在数组中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想存储元素就像从数据库到数组变量的堆栈推送操作一样,我试过但它没有正确地存储数组中的元素。所以任何人都可以建议我如何在数组中存储元素我的代码是..





<前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,那么如何将这两个元素存储在数组中,如堆栈

解决方案

如果两个返回行,将两者都添加到数组列表中。


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..


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 stack

解决方案

If two rows are returned, add both to the array list.


这篇关于如何在C#中将所有元素存储在数组中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆