【发布时间】:2013-03-26 08:35:27
【问题描述】:
private string formatSizeBinary(Int64 size, Int32 decimals = 2)
{
string[] sizes = { "Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" };
double formattedSize = size;
Int32 sizeIndex = 0;
while (formattedSize >= 1024 & sizeIndex < sizes.Length)
{
formattedSize /= 1024;
sizeIndex += 1;
}
return string.Format("{0} {1}", Math.Round(formattedSize, decimals).ToString(), sizes[sizeIndex]);
}
我收到了
“不允许使用默认参数说明符”
"Int32 decimals = 2" 出错
【问题讨论】:
-
C# 中的可选参数仅在 C# 2010(和 VS2010)中引入。如果(如您的标签所示)您使用的是 .NET 2.0 和 VS2008,那么错误消息几乎是不言自明的。你有什么问题?
标签: c# visual-studio-2008 .net-2.0