Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/313.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在C中修复这些错误?_C#_.net_Compiler Errors - Fatal编程技术网

C# 如何在C中修复这些错误?

C# 如何在C中修复这些错误?,c#,.net,compiler-errors,C#,.net,Compiler Errors,这是我遇到错误的代码: this.terminchar = Convert.ToChar(8080); List<string> source = new List<string>(this.base64Decode(parse_value).Split(new char[] { this.terminchar })); if ((source) % 2) == 0) { for (int i = 0; i < source; i++) {

这是我遇到错误的代码:

this.terminchar = Convert.ToChar(8080);    
List<string> source = new List<string>(this.base64Decode(parse_value).Split(new char[] { this.terminchar }));

if ((source) % 2) == 0)
{
  for (int i = 0; i < source; i++)
  {
    this.keys.Add(source[i], source[++i]);
  }
}
这段代码有3个错误,第一个:


错误1运算符“您可能在这两种情况下都在查找.Count属性


所以使用source.Count。

您需要使用source上的.Count来获取列表中项目的计数

List<string> source = new List<string>(this.base64Decode(parse_value).Split(new    char[] { Convert.ToChar(8080) }));
string Command = source[0];
source.RemoveAt(0);
if ((source.Count) % 2) == 0)
{
    for (int i = 0; i < source.Count; i++)
    {
        this.keys.Add(source[i], source[++i]);
    }
}

显然,您可以在for循环中使用它。使用i可以对列表执行一些操作。我很确定,你应该把你的台词写在下面

if ((source.Count) % 2) == 0)  

相反

源是列表-字符串的容器,请参阅


运算符什么是源。长度?编译器会告诉您。对不起,它将包含count,因为它仍然是错误的,它是count。注意大写的首字母。此aint Java.List在C中没有.size
for (int i = 0; i < source.Count; i++)