static string FormatBytes( T input, bool shortFormat )

robot_2Generated
code_blocksInput

Description

The FormatBytes method is a static extension method provided by the SandboxSystemExtensions class. It is used to format a given input value, representing a number of bytes, into a human-readable string. The method can format the output in either a short or long format, depending on the shortFormat parameter.

Usage

To use the FormatBytes method, you need to call it on a numeric value representing bytes. The method takes two parameters:

  • input: The numeric value representing the number of bytes. This is a generic parameter T, which means it can be any numeric type.
  • shortFormat: A boolean value indicating whether the output should be in a short format (e.g., "1 KB") or a long format (e.g., "1 Kilobyte").

Example usage:

long bytes = 1024;
string formattedBytes = bytes.FormatBytes(true); // Output: "1 KB"

Example

long bytes = 1024;
string formattedBytes = bytes.FormatBytes(true); // Output: "1 KB"

int largeBytes = 1048576;
string formattedLargeBytes = largeBytes.FormatBytes(false); // Output: "1 Megabyte"