【发布时间】:2011-09-17 21:49:16
【问题描述】:
下面是我的代码。
public class PItem
{
public String content;
public int count;
public int fee;
public int amount;
public string description;
// Default values
public PItem(String _content = "", int _count = 0, int _fee = 0, string _description = "", int _amount = 0)
{
content = _content;
count = _count < 0 ? 0 : _count;
fee = _fee;
description = _description;
amount = _amount < 0 ? 0 : _amount;
}
}
这是在一个类里面。当我尝试运行一个程序时,它给出了这个错误:
不允许使用默认参数说明符
我该如何解决这个错误?
【问题讨论】:
-
你怎么知道你使用的是 C# 4.0?
-
这个错误发生在哪里?编译时?
-
yes akash.. 在编译时我遇到了这个错误
-
Gabe 对 C# 4.0 感到抱歉...我该如何解决我的问题
-
@hesamsalehnamadi:既然您已经解决了您的问题,您可能需要考虑通过编辑甚至删除您的问题来回馈一点,因为它具有误导性(您没有使用 C# 4)。跨度>
标签: c# compiler-errors .net-3.5 default-parameters