string ext = Path.GetExtension(file);
if (!files.Contains(file) && file.Contains(textBox2.Text))
{
files.Add(file);
}
Run Code Online (Sandbox Code Playgroud)
在textBox2.Text中,值为cs,或者如果我键入.cs或*.cs,我希望只有具有此cs扩展名的文件才会添加到List文件中.
第二个包含:file.Contains(textBox2.Text)错误,因为我想检查扩展名而不是任何有cs的地方.
String word = textBox1.Text;
string[] test = word.Split(",,");
Run Code Online (Sandbox Code Playgroud)
如果它与一个word.Split(",");它将工作正常.但在这种情况下,字符串格式为:hello,,hi,,50,,70
我想解析它,所以在数组中我将:
hello hi 50 70
Run Code Online (Sandbox Code Playgroud)
得到错误:word.Split(",,");
错误2字符文字中的字符太多
错误3'string.Split(params char [])'的最佳重载方法匹配具有一些无效参数
错误4参数1:无法从'string'转换为'char []'