Sparx Systems Forum
Enterprise Architect => General Board => Topic started by: DJ_Doena on July 14, 2005, 07:19:51 am
-
If I design a class and a method with a parameter that has a default value, C# code generation will generate this:
public class Foo
{
public Foo()
{
}
public void DoSomething(int i = 0)
{
}
}
That will bring the following error message:
Visual C# Language Concepts
Compiler Error CS0241Default 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);
}
}
--------------------------------------------------------------------------------
Send feedback on this topic to Microsoft
© Microsoft Corporation. All rights reserved.
-
This should be fixed in the next build of EA.
Until then, either don't model parameter default values for C# classes, or modify the C# parameter template and remove the last line.
Simon