拆分字符串错误:无法从字符串转换为字符

Sam*_*olm 1 c# unity-game-engine

我有以下代码:

textPath = Application.streamingAssetsPath + "JSONFiles/text_to_text.txt";
 StreamReader reader = new StreamReader(textPath);
 string text = reader.ReadLine();
 string[] colour = text.Split(",");
 m_textMeshPro.SetText(text);
 reader.Close();
Run Code Online (Sandbox Code Playgroud)

该代码正在从 txt 文件中读取一行。我在 unity 内部使用这个。但是,当我将鼠标悬停在 split 函数 (",") 内的参数下方时,有一条红线。它说“参数 1:无法从 'string' 转换为 'char'。

pre*_*ine 5

使用这个,用单引号替换双引号来指定一个字符。

string[] colour = text.Split(',');
Run Code Online (Sandbox Code Playgroud)