Answers:
RFC只是试图说一个有符号整数是一个普通的4字节整数,其字节以大端顺序排列。
现在,您很可能正在使用低端字节序的计算机,并且BitConverter.GetBytes()会得到byte[]相反的结果。因此,您可以尝试:
int intValue;
byte[] intBytes = BitConverter.GetBytes(intValue);
Array.Reverse(intBytes);
byte[] result = intBytes;但是,为了使代码具有最大的可移植性,您可以这样做:
int intValue;
byte[] intBytes = BitConverter.GetBytes(intValue);
if (BitConverter.IsLittleEndian)
    Array.Reverse(intBytes);
byte[] result = intBytes;byte[] result = intBytes;?还不intBytes是您想要的数组吗?
                    result在此代码段中是多余的。但是,我认为,向读者明确表明结果是比在假定他们可以弄清楚结果包含在名为的某个变量中更具教学意义intBytes。此外,进行分配很便宜,因为它既不复制内存也不分配新的内存,它只是向已分配的数组添加一个新名称。那么为什么不这样做呢?
                    这是另一种方式:众所周知1x字节= 8x位,并且,“常规”整数(int32)包含32位(4字节)。我们可以使用>>运算符将位右移(>>运算符不会更改值。)
int intValue = 566;
byte[] bytes = new byte[4];
bytes[0] = (byte)(intValue >> 24);
bytes[1] = (byte)(intValue >> 16);
bytes[2] = (byte)(intValue >> 8);
bytes[3] = (byte)intValue;
Console.WriteLine("{0} breaks down to : {1} {2} {3} {4}",
    intValue, bytes[0], bytes[1], bytes[2], bytes[3]);& 0xFF不需要数组初始化程序和xor(^)和位。
                    unchecked块中。当前,只有在编译器设置中禁用了整数溢出检查时,它才有效。
                    BitConverter.GetBytes(int) 几乎可以满足您的要求,除了字节序错误。
在使用或使用Jon Skeet的EndianBitConverter类之前,可以使用IPAddress.HostToNetwork方法在整数值内交换字节。两种方法都针对可移植性做了正确的事情。BitConverter.GetBytes
int value;
byte[] bytes = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(value));为什么上面的示例中所有这些代码...
具有显式布局的结构会同时起作用,并且不会影响性能。
更新:由于存在有关如何处理字节序的问题,因此我添加了一个界面,该界面说明了如何对其进行抽象。另一个实现结构可以处理相反的情况
public interface IIntToByte
{
    Int32 Int { get; set;}
    byte B0 { get; }
    byte B1 { get; }
    byte B2 { get; }
    byte B3 { get; }
}
[StructLayout(LayoutKind.Explicit)]
public struct IntToByteLE : UserQuery.IIntToByte
{
    [FieldOffset(0)]
    public Int32 IntVal;
    [FieldOffset(0)]
    public byte b0;
    [FieldOffset(1)]
    public byte b1;
    [FieldOffset(2)]
    public byte b2;
    [FieldOffset(3)]
    public byte b3;
    public Int32 Int {
        get{ return IntVal; }
        set{ IntVal = value;}
    }
    public byte B0 => b0;
    public byte B1 => b1;
    public byte B2 => b2;
    public byte B3 => b3; 
}另一种方法是像这样使用BinaryPrimitives
byte[] intBytes = BitConverter.GetBytes(123);
 int actual = BinaryPrimitives.ReadInt32LittleEndian(intBytes);
using static System.Console;
namespace IntToBits
{
    class Program
    {
        static void Main()
        {
            while (true)
            {
                string s = Console.ReadLine();
                Clear();
                uint i;
                bool b = UInt32.TryParse(s, out i);
                if (b) IntPrinter(i);
            }
        }
        static void IntPrinter(uint i)
        {
            int[] iarr = new int [32];
            Write("[");
            for (int j = 0; j < 32; j++)
            {
                uint tmp = i & (uint)Math.Pow(2, j);
                iarr[j] = (int)(tmp >> j);
            }
            for (int j = 32; j > 0; j--)
            {
                if(j%8==0 && j != 32)Write("|");
                if(j%4==0 && j%8 !=0) Write("'");
                Write(iarr[j-1]);
            }
            WriteLine("]");
        }
    }
}```byte[] Take_Byte_Arr_From_Int(Int64 Source_Num)
{
   Int64 Int64_Num = Source_Num;
   byte Byte_Num;
   byte[] Byte_Arr = new byte[8];
   for (int i = 0; i < 8; i++)
   {
      if (Source_Num > 255)
      {
         Int64_Num = Source_Num / 256;
         Byte_Num = (byte)(Source_Num - Int64_Num * 256);
      }
      else
      {
         Byte_Num = (byte)Int64_Num;
         Int64_Num = 0;
      }
      Byte_Arr[i] = Byte_Num;
      Source_Num = Int64_Num;
   }
   return (Byte_Arr);
}Int16。