Click here to Skip to main content
15,912,932 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

C#
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;
}
Posted
Updated 16-Feb-14 19:43pm
v4

1 solution

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()
 
Share this answer
 
Comments
wmdroshan 17-Feb-14 3:33am    
Yes. 'input string is not in correct format' has nothing to do with passing an ArrayList. Convert.ToDouble(lblUserToFamilyID.ToString()) is the problem. This returns a type name. So, it can't be converted into a double.
SVT02 17-Feb-14 23:13pm    
Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900