Click here to Skip to main content
15,886,844 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,
I have created a class in which I am reading through a DB and populating an array. The array gets loaded fine.
I am then calling for the contents of that array from another Windows Form. The problem that I am having is that when I call to populate the list box in the form all I see is "Double[] Array" inside of the listbox instead of the contents of the array.
Thanks again!


This is my property:


C#
public double[] My_Array
{
    get
   {
       return priv_rd_dblTestArray;
    }
    set
    {
       priv_rd_dblTestArray = value;
    }


 }



This is the call to the property values:

listBox2.Items.Add(eCirc_Read.My_Array);


This is the result inside of the listbox:

"Double[] Array"
Posted

1 solution

That's because a listbox shows strings, and the ToString() method for your array returns its' type if no override is provided.

Try updating your listbox this way:

C#
foreach(double value in eCirc_Read.My_Array)
{
    listBox2.Items.Add(Convert.ToString(value));
}
 
Share this answer
 
v2
Comments
WhiskeyBusiness 3-Feb-11 12:14pm    
Wonderful! Thank you for your help John.

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