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.


7 Years
Discussion Span
Last Post by nick.crane

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;

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.