KB,MB,GB,TB

/// <summary>
/// Kilobytes
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static int KB(this int value)
{
	return value * 1024;
}

/// <summary>
/// Megabytes
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static int MB(this int value)
{
	return value.KB() * 1024;
}

/// <summary>
/// Gigabytes
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static int GB(this int value)
{
	return value.MB() * 1024;
}

/// <summary>
/// Terabytes
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static long TB(this int value)
{
	return (long)value.GB() * (long)1024;
}
Example:
var 1kb = 1.KB();
var 1mb = 1.MB();
var 1gb = 1.GB();
var 1tb = 1.TB();

Description

Simplest way to get a number of bytes at different measures. KB, MB, GB or TB,

Details

Double click on the code to select all.

 

;