user1925442
user1925442

Reputation: 45

How to split string and take characters from it?

Have next lines:

var line1 = File.ReadLines(@"input_5_5.txt").Take(1).ToArray();
string[] u = line1.Split(new Char[] { ' ' });
int[,] result = new int[u[0], u[1]];

Need to split and take characters from line1 to initialize size of array but it runs error about word "Split".

Upvotes: 0

Views: 63

Answers (1)

Shaharyar
Shaharyar

Reputation: 12459

line1 is an array.

You need to cast it to string:

(line1[0] as String).Split(...

or simply

line1[0].Split(...

Upvotes: 3

Related Questions