编译器错误 CS0186

更新:2007 年 11 月

错误消息

在此上下文中使用 NULL 无效

下面的示例生成 CS0186:

// CS0186.cs
using System;
using System.Collections;

class MyClass 
{
   static void Main() 
   {
      // Each of the following lines generates CS0186:
      foreach (int i in null) {}   // CS0186
      foreach (int i in (IEnumerable) null) { };   // CS0186
   }
}