c# - adding data to a 2d array in a methodical manner -
i have need create 2 d array. in array there strings, id., resistance values, , date,
these entered each time, array size 7x16 info require,
how can prompt user entry of code without big long entries in code? reading c# books im weak on loops, can point me of loop can assist in skills on this,
any assistance welcomed, steven
using system; using system.globalization; // has included, not in docs! using system.io; using system.text; using system.collections.generic; using system.linq; public class celldetails { public static void main() { console.writeline("enter value cell id, sample, write/tx, depass, discharge date , discharge load"); string[,] celldetailarray = new string[7, 16]; // sets element @ index 0,0. celldetailarray.setvalue("pmx150_01", 0, 0); console.writeline("cell identifier {0}", celldetailarray.getvalue(0, 0)); console.readline(); } }
i not sure if want, may help:
static void main(string[] args) { console.writeline("enter values cell id, sample, write/tx, depass, discharge date , discharge load."); string[,] celldetailarray = new string[16, 6]; (int = 0; < celldetailarray.getlength(0); i++) { console.writeline(string.format("data row no. {0}:", + 1)); (int j = 0; j < celldetailarray.getlength(1); j++) { console.write(string.format("\tvalue column no. {0}: ", j + 1)); celldetailarray[i, j] = console.readline(); } } console.writeline("data entry finished.\n\narray contents:"); (int = 0; < celldetailarray.getlength(0); i++) { console.write(string.format("\nrow no. {0}: ", + 1)); (int j = 0; j < celldetailarray.getlength(1); j++) { console.write(string.format("\"{0}\"", celldetailarray[i, j])); if (j < celldetailarray.getlength(1) - 1) console.write(", "); } } }
note: array must 7x16, list 6 fields, made array 6x16 (16 rows 6 fields).
c# arrays loops 2d
No comments:
Post a Comment