Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string[][] jagged = new string [100][];
- //...jagged array is populated...
- dataGridView1.DataSource = jagged;
- //
- // 1. Create two dimensional array
- //
- const int dim = 1000;
- double[,] array = new double[dim,dim];
- Random ran = new Random();
- for(int r = 0; r < dim; r++)
- {
- for(int c = 0; c < dim; c++)
- {
- array[r,c] = (ran.Next(dim)); // fill it with random numbers.
- }
- }
- // 2. Create ArrayDataView class in which
- // constructor you pass the array
- // and assign it to DataSource property of DataGrid.
- dataGrid1.DataSource = new ArrayDataView(array);
- string[][] arr = new string[2][];
- arr[0] = new String[] {"a","b"};
- arr[1] = new String[] {"c","d"};
- DataGrid1.DataSource = arr[0];
- DataGrid1.DataBind();//The result is: a,b in datagrid
- List<string> names = new List<string>(new string[]
- {
- "John",
- "Frank",
- "Bob"
- });
- var bindableNames =
- from name in names
- select new {Names=name};
- dataGridView1.DataSource = bindableNames.ToList();
- string[][] stringRepresentation = ds.Tables[0].Rows
- .OfType<DataRow>()
- .Select(r => ds.Tables[0].Columns
- .OfType<DataColumn>()
- .Select(c => r[c.ColumnName].ToString())
- .ToArray())
- .ToArray();
Add Comment
Please, Sign In to add comment