本文整理汇总了C#中System.Int32.ToBinary方法的典型用法代码示例。如果您正苦于以下问题:C# Int32.ToBinary方法的具体用法?C# Int32.ToBinary怎么用?C# Int32.ToBinary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Int32
的用法示例。
在下文中一共展示了Int32.ToBinary方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteInt32
/// <summary>
/// Writes a signed 32-bit integer to the StreamEx.
/// </summary>
/// <param name="b">32-bit signed integer.</param>
/// <param name="seq">Byte sequence a.k.a endianness.</param>
public void WriteInt32(Int32 b, BitOrder seq = BitOrder.LittleEndian)
{
Write(b.ToBinary(seq), 0, 4);
}
示例2: TestMultidimensionalArray
public void TestMultidimensionalArray()
{
Int32[,,] array3d = new Int32[2, 2, 3] { { { 1, 2, 3 }, { 4, 5, 6 } },
{ { 7, 8, 9 }, { 10, 11, 12 } } };
Byte [] binary = array3d.ToBinary <Int32[,,]> ();
Int32[,,] result = binary.FromBinary <Int32[,,]> ();
for (Int32 i = 0; i < 2; ++i)
{
for (Int32 j = 0; j < 2; ++j)
{
for (Int32 k = 0; k < 3; ++k)
{
Assert.That (array3d [i,j,k] == result [i,j,k]);
}
}
}
}
示例3: TestNormalValueArray
public void TestNormalValueArray()
{
Int32[] array = new Int32 [6] { 0, 1, 2, 3, 4, 5};
Byte [] binary = array.ToBinary <Int32[]> ();
Int32[] result = binary.FromBinary <Int32[]> ();
for (Int32 i = 0; i < array.Length; ++i)
{
Assert.That (array [i] == result [i]);
}
}
示例4: TestJaggedArray
public void TestJaggedArray()
{
Int32[][] jaggedArray = new Int32 [5][];
jaggedArray [0] = new Int32[2] { 0, 1 };
jaggedArray [1] = new Int32[4] { 1, 2, 3, 4};
jaggedArray [2] = new Int32[6] { 2, 3, 4, 5, 6, 7};
jaggedArray [3] = new Int32[8] { 3, 4, 5, 6, 7, 8, 9, 10};
jaggedArray [4] = new Int32[10] { 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
Byte [] binary = jaggedArray.ToBinary <Int32[][]> ();
Int32[][] result = binary.FromBinary <Int32[][]> ();
for (Int32 i = 0; i < jaggedArray.Length; ++i)
{
for (Int32 j = 0; j < jaggedArray [i].Length; ++j)
{
Assert.That (jaggedArray [i][j] == result [i][j]);
}
}
}