Export (0) Print
Expand All
Expand Minimize

Compiler Error CS0117

'type' does not contain a definition for 'function'

A call was made to a method that does not exist for the data type. This can also happen when a class name and its enclosing namespace name are the same and when a qualified method is called.

The following sample generates CS0117:

// CS0117_1.cs
namespace x
{
   public class a
   {
      public static void Main()
      {
         int i;
         i = i.get();   // CS0117, no get method on an int
      }
   }
}

When using indexers, it is not necessary to use the Item specifier:

// CS0117_2.cs
using System;
using System.Collections;
 
class Test
{
   public static void Main()
   {
      ArrayList al = new ArrayList();
      al.Add( new Test() );
      al.Add( new Test() );
      Console.WriteLine("First Element is {0}", al.Item[0]);   // CS0117
      // try the following line instead
      // Console.WriteLine("First Element is {0}", al[0]); 
   }
}
Show:
© 2014 Microsoft