如何将arraylist变量传递给c#中的函数 [英] How to pass the arraylist variable to the function in c#

查看:178
本文介绍了如何将arraylist变量传递给c#中的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是c#的新手,我想将Arraylist变量传递给CompareArrayList函数,但是错误是输入字符串格式不正确,任何人都可以告诉我,如何将arraylist变量传递给函数在c#中,我的代码在下面



Hi,I am new to c# ,I want to pass the Arraylist variable to the function CompareArrayList,But error is that 'input string is not in correct format' ,Can anyone tell me ,how to pass the arraylist variable to the function in c#, my code is below

protected void RelativeFamilyIDFrom(Double RelativeMemberID)
{
        sSQL = "SELECT AF_FamilyID FROM AllFamily_Master";
        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(Convert.ToDouble(DS.Tables["table"].Rows[i]["AF_FamilyID"].ToString()));

                }
                CompareArrayList(list, Convert.ToDouble(lblUserToFamilyID.ToString()));
            }
        }
}

private bool CompareArrayList(ArrayList RelativeFamilyID,Double arr2)
{
        for (int i = 0; i < RelativeFamilyID.Count; i++)
        {
            if (!arr2.Equals(RelativeFamilyID[i]))
            return false;

        }
          return true;
}

推荐答案

看起来像将lblUserToFamilyID值转换为Double时发生错误。调试lblUserToFamilyID的值。



如果lblUserToFamilyID是一个控件,那么使用lblUserToFamilyID.Text.ToString()
It look likes error occured while converting lblUserToFamilyID value to Double. Debug the value of lblUserToFamilyID.

if lblUserToFamilyID is a control then use lblUserToFamilyID.Text.ToString()


这篇关于如何将arraylist变量传递给c#中的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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