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

标签 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.keys.Add(source[i], source[++i]);
  }
}

我在此代码中遇到3个错误,第一个错误:

Error 1 Operator '<' cannot be applied to operands of type 'int' and 'System.Collections.Generic.List'



第二个:

Error 2 Operator '%' cannot be applied to operands of type 'System.Collections.Generic.List' and 'int'



第三个:

Error 3 Invalid expression term '=='



我对C#相当陌生,这是我的 friend 源代码,我只是想了解其语法,但是我不知道该怎么做。给出的任何帮助将不胜感激,谢谢。

最佳答案

您正在对列表执行一些操作。我很确定,您应该按照以下步骤进行操作...

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


for (int i = 0; i < source.Count; i++)

代替

关于c# - 如何在C#中修复这些错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7307198/

相关文章:

c# - 如何以编程方式检查 .NET 中的有效删除(修改)或写入权限?

c# - Entity Framework 插入多对多创建重复数据

c# - 内联构造函数和 InjectFrom 调用返回对象

c# - 在 C# 中加载 XML 文件路径

objective-c - 使用宏指向行时出现预期的 ')' 编译错误

c# - Xamarin 和 Google map 上的距离不同

c# - 使用 TCP 发送多个字符串太快了我该如何等待?

.net - 在 FontDialog 中显示颜色选项,没有下划线和删除线选项

c# - 新的WPF项目将无法编译-抛出错误 “The name ' InitializeComponent'在当前上下文中不存在”

c - 错误: 'for' loop initial declarations are only allowed in c99 mode