You will have to revert to overloading the method if you want this functionality because in C# 2.0 "default parameter specifiers are not permitted".
private string formatSizeBinary(Int64 size)
{
return formatSizeBinary(size, 2);
}
private string formatSizeBinary(Int64 size, Int32 decimals)
{
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]);
}