Compiler Warning (level 2) CS0108
'member1' hides inherited member 'member2'. Use the new keyword if hiding was intended.
A variable was declared with the same name as a variable in a base class. However, the new keyword was not used. This warning informs you that you should use new; the variable is declared as if new had been used in the declaration.
The following sample generates CS0108:
// CS0108.cs
// compile with: /W:2
using System;
namespace x
{
public class clx
{
public int i = 1;
}
public class cly : clx
{
public static int i = 2; // CS0108, use the new keyword
// Use the following line instead:
// public static new int i = 2;
public static void Main()
{
Console.WriteLine(i);
}
}
}