Size To Readable String - CSharp System

CSharp examples for System:Byte

Description

Size To Readable String

Demo Code



public class Main{
        public static string ToReadableString(this long size)
        {//  w ww  . j av a  2 s. co  m
            if (size / 1000000L > 0L)
            {
                return (size / 10000L / 100.0).ToString() + "M";
            }
            if (size / 1000L > 0L)
            {
                return (size / 10L / 100.0).ToString() + "K";
            }
            return "< 1k";
        }
}

Related Tutorials