C# Static Indexer Should Not Compile, but Does
I realize we cannot have static indexers in C#. But the why does the code below compile correctly (under C# 4.0)?

Since Fred is a static class, it cannot even be instantiated. The declared static indexer makes no sense yet the compiler allows it. Why? I can't imagine it's a compiler bug this late into the language.

    public static class Fred {
      public static int this[String str] {
        get {
          if (str != null)
            return str.Length;

          return -1;
        }
      }
    }
C# Static Indexer Should Not Compile, but Does
===

I realize we cannot have static indexers in C#. But the why does the code below compile correctly (under C# 4.0)?

Since Fred is a static class, it cannot even be instantiated. The declared static indexer makes no sense yet the compiler allows it. Why? I can't imagine it's a compiler bug this late into the language.

    public static class Fred {
      public static int this[String str] {
        get {
          if (str != null)
            return str.Length;

          return -1;
        }
      }
    }