Hi Everyone,

Im a little confused with arrays[]

I have a set of numbers in a datagridview and wish to write a function which includes these numbers. I know i can use
double[] arrayOfDoubles = {2.5,2.6,2.8,3.2,3.8,3.9,4.0,4.3,4.4,4.8} etc representing each datagrid value individually. just wondering if there is a easier way with a loop.

your help would be appreciated.


Clarify your question. Where are those numbers coming from? Why would you want a loop? What are you using them for?

If those are arbitrary numbers that you are going to refer to later, then doing it like you are is just great. If they are being read in from something else, then yeah, put it in a loop and add the values to the array as you go. Though if you're doing that, I'd turn it into a List<double> , and use List.Add(item) in the loop.

To get the values from cells in a datagridview you can reference each cell with co-ordinates using dataGridView1[col, row].Value;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.