我正在尝试读取ConfigFile(txt文件),其中以这种形式包含一些参数:“ showHelp = F1”
static List <string> read(string path)
{
List<string >lines = File.ReadAllLines(path).ToList();
if (lines == null)
{ Debug.Log("empty file"); }
return lines;
}
public static Dictionary<string, string> ReadConfigFile (string path)
{
List<string> Lines =new List<string>();
Lines = read(path);
Dictionary<string, string> content = new Dictionary<string, string>();
foreach (string line in Lines)
{
if (line.Contains('=') == false)
{ continue;}
string replaced = Regex.Replace(line, @"\p{C}+", string.Empty);
string[] split = replaced.Split('=');
content.Add(split[0], split[1]);
}
return (content);
}
错误在于content.add(split [0],split [1])?