Compiler Errors CS0001 Thro ...


Visual C# Language Concepts
Compiler Error CS0241

Default parameter specifiers are not permitted

Method parameters cannot have default values. Use method overloads if you want to achieve the same effect.

The following sample generates CS0241:

// CS0241.cs
public class TestClass
{
   public void TestMethod(int i = 9)   // CS0241
   // try the following line instead
   // public void TestMethod(int i)
   {
   }

   public static void Main()
   {
      TestClass x = new TestClass();
      x.TestMethod(9);
   }
}
Page view tracker