Sunday 15 April 2012

arrays - Cropping lines and columns in String[n,m] C# -


I have a 'matrix' of the string that I saved as string [m, n] Believe, whith meter lines and n pillar).

I would like to know the best way to crop the entire column of the entire line or array of the crop.

For example, what is the best way to remove all m = 1 indexed entries (second row of matrix), such as the third row automatically becomes second, finally the fourth third and much more Gets ahead ...).

Any help is greatly appreciated. Thank you.

keyword rows , column , Excel table gave me a hint

DataTable class in System.Data namespace, which can do almost all You are asking about it (except that there are no values ​​in the object type, string .}

example

  Int cols = 100; int rows = 500; System.Data.DataTable.dt = new datatile (); for (int c = 0; c & lt; cols; c ++) dt.Columns.Add "Col_" + c); A (int r = 0; r> l> rows; r ++) for {dt.Rows.Add (); (int c = 0; c  

?

 < Code> string value_row2_colum_5 = dt.rows [2] .field & lt; string & gt; (5); string value_row20_colum_50 = dt.rows [20] [50] .restring ();  
< P> How to set prices?

  dt.rows [2] [5] = "set";  

How to remove columns?

Datatyale has the column property, you can remove any of them, e.g.

  dt.Columns.RemoveAt (0);  

How to remove the row?

Datatyla has rows assets you can remove any of them, e.g.

  dt.Rows.RemoveAt (0);  

Also the select and compute methods in datatable which are very useful in some cases


No comments:

Post a Comment