Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Compiler Error CS0241
Collapse the table of content
Expand the table of content

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);
   }
}
Show:
© 2015 Microsoft