小编Zai*_*wad的帖子

将字符串从文本文件转换为整数数组

我编写此代码是为了以C#语言打开文本文件.文件中的每一行都包含五个数字,如

0    0    2    3     6

0    1    4    4     7

0    2    6    9     9

1    0    8    11    9

1    1    12   15    11

2    2    12   17    15
Run Code Online (Sandbox Code Playgroud)

数字和另一个之间的距离是一个选项卡问题是当您执行程序时出现此错误

Convert.ToInt32(t [j])中的输入字符串格式不正确

码:

string[] st = File.ReadAllLines("C:\\testing\\result.txt");
int[,] tmp = new int[st.Length - 1, 5];
for (int i = 1; i < st.Length; i++)
{

   string[] t = st[i].Split(new char[] { ' ' });
   int cnt = 0;
   for (int k = 0; k < t.Length; k++)
        if …
Run Code Online (Sandbox Code Playgroud)

c# integer file

4
推荐指数
1
解决办法
195
查看次数

标签 统计

c# ×1

file ×1

integer ×1