Beispiel #1
0
        public string ToString(bool shortFormat)
        {
            if (Math.Abs(TotalPetabytes) >= 1)
            {
                return(TotalPetabytes.ToString("0.##") + ' ' + (shortFormat ? "PB" : "petabytes"));
            }

            if (Math.Abs(TotalTerabytes) >= 1)
            {
                return(TotalTerabytes.ToString("0.##") + ' ' + (shortFormat ? "TB" : "terabytes"));
            }

            if (Math.Abs(TotalGigabytes) >= 1)
            {
                return(TotalGigabytes.ToString("0.##") + ' ' + (shortFormat ? "GB" : "gigabytes"));
            }

            if (Math.Abs(TotalMegabytes) >= 1)
            {
                return(TotalMegabytes.ToString("0.##") + ' ' + (shortFormat ? "MB" : "megabytes"));
            }

            if (Math.Abs(TotalKilobytes) >= 1)
            {
                return(TotalKilobytes.ToString("0.##") + ' ' + (shortFormat ? "KB" : "kilobytes"));
            }

            // ReSharper disable once ImpureMethodCallOnReadonlyValueField
            return(bytes.ToString() + ' ' + (shortFormat ? "B" : "bytes"));
        }
Beispiel #2
0
        public string ToString(bool shortFormat)
        {
            if (Math.Abs(TotalPetabytes) >= 1)
            {
                return(TotalPetabytes.ToString("0.##") + ' ' + (shortFormat ? "PB" : "petabytes"));
            }

            if (Math.Abs(TotalTerabytes) >= 1)
            {
                return(TotalTerabytes.ToString("0.##") + ' ' + (shortFormat ? "TB" : "terabytes"));
            }

            if (Math.Abs(TotalGigabytes) >= 1)
            {
                return(TotalGigabytes.ToString("0.##") + ' ' + (shortFormat ? "GB" : "gigabytes"));
            }

            if (Math.Abs(TotalMegabytes) >= 1)
            {
                return(TotalMegabytes.ToString("0.##") + ' ' + (shortFormat ? "MB" : "megabytes"));
            }

            if (Math.Abs(TotalKilobytes) >= 1)
            {
                return(TotalKilobytes.ToString("0.##") + ' ' + (shortFormat ? "KB" : "kilobytes"));
            }

            return(bytes.ToString() + ' ' + (shortFormat ? "B" : "bytes"));
        }