Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio .NET
Reference
Visual C# Language
C# Compiler Options
 Compiler Error CS0176

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2003/.NET Framework 1.1

Other versions are also available for the following:
Visual C# Language Concepts
Compiler Error CS0176

Static member 'member' cannot be accessed with an instance reference; qualify it with a type name instead

Only a class name can be used to qualify a static variable; an instance name cannot be a qualifier.

The following sample generates CS0176:

// CS0176.cs
public class b
{
   public static int ii;
}

public class a
{
   public static void Main()
   {
      b bb = new b();
      int i = bb.ii;   // CS0176
      // try the following line instead
      // int i = b.ii;
   }
}
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker