Lidgren.Network.NetUtility.ToHumanReadable C# (CSharp) Méthode

ToHumanReadable() public static méthode

Converts a number of bytes to a shorter, more readable string representation
public static ToHumanReadable ( long bytes ) : string
bytes long
Résultat string
		public static string ToHumanReadable(long bytes)
		{
			if (bytes < 4000) // 1-4 kb is printed in bytes
				return bytes + " bytes";
			if (bytes < 1000 * 1000) // 4-999 kb is printed in kb
				return Math.Round(((double)bytes / 1000.0), 2) + " kilobytes";
			return Math.Round(((double)bytes / (1000.0 * 1000.0)), 2) + " megabytes"; // else megabytes
		}