我正在尝试将我的数组中的每一行字符串打印到一个单独的文本文件中,但我的数据源中似乎没有带索引的数组,我一直在WriteAllLines()
的数据源中方法,错误:
错误CS1503参数2:无法转换为'字符串'到' string []'
有T_tag[l]
。
有人可以帮我理解这个错误吗?
string[] Colmn_No = ColmnN.ToArray();
int ArrayLength = Colmn_No.Length;
string[] Cleantag = new string[ArrayLength];
string[] CleanCage = new string[ArrayLength];
for (int i = 0; i <= ArrayLength - 1; i++)
{
Cleantag[i] = Colmn_SmpNm[i].Trim().ToUpper();
CleanCage[i] = Colmn_Cage[i].Trim().ToUpper();
}
string[] T_tag = new string[ArrayLength];
string[] A_tag = new string[ArrayLength];
for (int k = 0, l=0, m=0; k <= ArrayLength - 1; k++)
{
if (Cleantag[k].StartsWith("T"))
{
T_tag[l] = "<T>"+ Cleantag[k]+"</T><C>C</C><V>"+ CleanCage[k]+"</V>";
System.IO.File.WriteAllLines((RRfolder + "//" + Cleantag[k] + ".txt"), T_tag[l]);
l++;
}
答案 0 :(得分:1)
//System.IO.File.WriteAllLines((RRfolder + "//" + Cleantag[k] + ".txt"), T_tag[l]);
1)写1行
System.IO.File.WriteAllText((RRfolder + "//" + Cleantag[k] + ".txt"), T_tag[l]);
2)或者,写下所有行(在for循环之外做)
System.IO.File.WriteAllLines((RRfolder + "//" + Cleantag[k] + ".txt"), T_tag);