代码错误消息 [英] Code error message
本文介绍了代码错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么这段代码会返回
"line 8, Argument 1: cannot convert
from'System.Collections.Generic.List<string>' to 'string'
我尝试过:
What I have tried:
List<string> strs1 = new List<string>();
string[] strArrays = Directory.GetFiles(str1);
for (int j = 0; j < (int)strArrays.Length; j++)
{
strs1.Add(Path.GetFileName(strArrays[j]));
}
richTextBox1.AppendText(string.Concat("New files in folder", str1, " : "));
richTextBox1.AppendText(strs1);
推荐答案
您已将strs1
声明为列出< string>
,但你是tr ying将它用作一个简单的字符串。您还有一个名为str1
的其他地方声明的变量,可能会造成混淆。
You have declaredstrs1
as aList<string>
, but you are trying to use it as a simple string. You also have a variable declared elsewhere namedstr1
, maybe that is causing the confusion.
因为附加文本 [ ^ ]方法一个RichTextBox需要一个字符串参数。
你传递一个字符串列表
Because the AppendText [^] method of a RichTextBox expects a string parameter.
You are passing a list of strings
这篇关于代码错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文