Int64 - GetBytes

Returns the specified 64-bit signed integer value as an array of bytes.

Try it

const string formatter = "{0,-30}{1,-30}";

public static void GetBytesInt16(Int64 argument)
{
	// C# Extension Method: Int64 - GetBytes
    byte[] byteArray = argument.GetBytes();
    Console.WriteLine(formatter, argument, BitConverter.ToString(byteArray));
}

public static void Main()
{
    Console.WriteLine(formatter, "Int32", "byte array");
    Console.WriteLine(formatter, "-----", "----------");

    GetBytesInt16(0);
    GetBytesInt16(15);
    GetBytesInt16(-15);
    GetBytesInt16(10000);
    GetBytesInt16(-10000);
    GetBytesInt16(Int64.MinValue);
    GetBytesInt16(Int64.MaxValue);
}

View Source
using System;

public static partial class Extensions
{
    /// <summary>
    ///     Returns the specified 64-bit signed integer value as an array of bytes.
    /// </summary>
    /// <param name="value">The number to convert.</param>
    /// <returns>An array of bytes with length 8.</returns>
    public static Byte[] GetBytes(this Int64 value)
    {
        return BitConverter.GetBytes(value);
    }
}