简体   繁体   中英

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".

line1 is an array.

You need to cast it to string:

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

or simply

line1[0].Split(...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM