企业架构师:C# 可选参数?
有没有办法让 Enterprise Architect 识别 C# 中的可选参数?
我尝试导入现有代码并收到以下错误:
解析时出错 C:\MyProject\FooBar.cs 第 30 行。 意外符号:=
代码:
public void Foo(int bar = 1) //Line 30
{
}
我也尝试从头开始并从 Enterprise Architect 生成代码。我创建了一个类,然后向该类添加了一个操作并定义了参数。用于编辑参数的表单允许我提供“名称”、“类型”和“默认”(以及其他信息)。我添加了名称:bar,类型:int,默认值:1。然后,当我生成代码时,这就是我得到的(没有生成可选参数!)
namespace System {
public class FooBar {
///
/// <param name="bar"></param>
public void Foo(int bar){
}
}//end FooBar
}//end namespace System
我做错了什么?
Any option to get Enterprise Architect to recognize optional parameters in C#?
I have attempted to import existing code and get the following error:
There was an error parsing
C:\MyProject\FooBar.cs on line 30.
Unexpected symbol: =
Code:
public void Foo(int bar = 1) //Line 30
{
}
I have also attempted to start from scratch and generate code from Enterprise Architect. I created a class, then added an operation to that class and defined the parameters. The form for editing parameters allows me to supply the "Name", "Type", and "Default" (as well as other information). I added Name: bar, Type: int, Default: 1. Then when I generated the code this is what I get (no optional parameter generated!)
namespace System {
public class FooBar {
///
/// <param name="bar"></param>
public void Foo(int bar){
}
}//end FooBar
}//end namespace System
What am I doing incorrectly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Sparx 刚刚发布了 EA 的版本 9,它支持C#4.0。
Sparx has just released version 9 of EA, which has support for C# 4.0.
C# 4.0 及更高版本支持可选参数。如果您使用的是旧版本,那么使用它们将根本不起作用并导致您提到的错误。
Optional parameters are supported from C# 4.0 and up. If you are using an older version then using them will simply not work and result in the error you are mentioning.