作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
是否可以在 C# 中为 PageSize 的默认参数设置值?例如:
public virtual void Render(string reportTitle, Rectangle pageSize = PageSize.A4)
{
foreach (Page p in pages)
{
p.Render(document);
document.NewPage();
document.AddCreationDate();
document.AddTitle(reportTitle);
document.SetPageSize(pageSize);
}
}
我在 Visual Studio 2010 中出现以下错误:
Default parameter value for 'pageSize' must be a compile-time constant.
最佳答案
当你写的时候;
Rectangle pageSize = PageSize.A4
您的 pageSize
值可以作为参数更改。
来自 Named and Optional Arguments
A default value must be one of the following types of expressions:
a constant expression;
an expression of the form new ValType(), where ValType is a value type, such as an enum or a struct;
an expression of the form default(ValType), where ValType is a value type.
表达式 PageSize.A4
未归类为 compile-time constant .
关于c# - 默认参数 PageSize A4 C# 使用 itextsharp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15365416/
我是一名优秀的程序员,十分优秀!