<分区>
我将我的变量保存到一串数据中,然后尝试将这些字符串转换回变量,如下所示:
using System;
public class Program
{
static int pop;
static string[] log = new string[10];
public static void Main()
{
string abc = "5 6 10 345 23 45";
log = abc.Split(' ');
Conv(3,pop);
Console.WriteLine(pop); // expected result: pop == 345
}
static void Conv(int i, int load)
{
if (log[i] != null){ load = int.Parse(log[i]);}
}
}
Pop 应为 345,但返回 0。使用时没有问题
pop = int.Parse.log[i]