input - easiest way to take file into an array? - c# -
i have file of integers. first number - number of subsequent numbers. easiest way take file array? c#
example 1: 8 1 2 3 4 5 6 7 8
example 2: 4 1 2 3 0
example 3: 3 0 0 1
int[] numbers = file .readalltext("test.txt") .split(' ') .select(int.parse) .skip(1) .toarray();
or if have number per line:
int[] numbers = file .readalllines("test.txt") .select(int.parse) .skip(1) .toarray();
Comments
Post a Comment