| 名 稱 | 說 明 |
| GetBytes(Boolean) | 傳回指定的布林值為位元組陣列。 |
| GetBytes(Char) | 傳回指定的 Unicode 位元值為位元組陣列。 |
| GetBytes(Double) | 傳回指定的雙精確度浮點數值為位元組陣列。 |
| GetBytes(Int16) | 傳回指定的 16 位元帶正負號的整數值為位元組陣列。 |
| GetBytes(Int32) | 傳回指定的 32 位元帶正負號的整數值為位元組陣列。 |
| GetBytes(Int64) | 傳回指定的 64 位元帶正負號的整數值為位元組陣列。 |
| GetBytes(Single) | 傳回指定的單精確度浮點數值為位元組陣列。 |
| GetBytes(UInt16) | 傳回指定的 16 位元不帶正負號的整數值為位元組陣列。 |
| GetBytes(UInt32) | 傳回指定的 32 位元不帶正負號的整數值為位元組陣列。 |
| GetBytes(UInt64) | 傳回指定的 64 位元不帶正負號的整數值為位元組陣列。 |
範例執行結果:
====================================================
long byte array
---------------------- -----------------------
0 00-00-00-00-00-00-00-00
16777215 FF-FF-FF-00-00-00-00-00
-16777215 01-00-00-FF-FF-FF-FF-FF
1000000000 00-CA-9A-3B-00-00-00-00
-1000000000 00-36-65-C4-FF-FF-FF-FF
4294967296 00-00-00-00-01-00-00-00
-4294967296 00-00-00-00-FF-FF-FF-FF
187649984473770 AA-AA-AA-AA-AA-AA-00-00
-187649984473770 56-55-55-55-55-55-FF-FF
1000000000000000000 00-00-64-A7-B3-B6-E0-0D
-1000000000000000000 00-00-9C-58-4C-49-1F-F2
-9223372036854775808 00-00-00-00-00-00-00-80
9223372036854775807 FF-FF-FF-FF-FF-FF-FF-7F
====================================================
// Example of the BitConverter.GetBytes( long ) method.using System;class GetBytesInt64Demo{const string formatter = "{0,22}{1,30}";
// Convert a long argument to a byte array and display it.public static void GetBytesInt64( long argument )
{ byte[] byteArray = BitConverter.GetBytes( argument );Console.WriteLine( formatter, argument,
BitConverter.ToString( byteArray ) );
}
public static void Main( )
{Console.WriteLine(
"This example of the BitConverter.GetBytes( long ) " + "\nmethod generates the following output.\n" );Console.WriteLine( formatter, "long", "byte array" );
Console.WriteLine( formatter, "----", "----------" );
// Convert long values and display the results.GetBytesInt64( 0 );
GetBytesInt64( 0xFFFFFF );
GetBytesInt64( -0xFFFFFF );
GetBytesInt64( 1000000000 );
GetBytesInt64( -1000000000 );
GetBytesInt64( 0x100000000 );
GetBytesInt64( -0x100000000 );
GetBytesInt64( 0xAAAAAAAAAAAA );
GetBytesInt64( -0xAAAAAAAAAAAA );
GetBytesInt64( 1000000000000000000 );
GetBytesInt64( -1000000000000000000 );
GetBytesInt64( long.MinValue ); GetBytesInt64( long.MaxValue );}
}
/*This example of the BitConverter.GetBytes( long )method generates the following output. long byte array ---- ---------- 0 00-00-00-00-00-00-00-00 16777215 FF-FF-FF-00-00-00-00-00 -16777215 01-00-00-FF-FF-FF-FF-FF 1000000000 00-CA-9A-3B-00-00-00-00 -1000000000 00-36-65-C4-FF-FF-FF-FF 4294967296 00-00-00-00-01-00-00-00 -4294967296 00-00-00-00-FF-FF-FF-FF 187649984473770 AA-AA-AA-AA-AA-AA-00-00 -187649984473770 56-55-55-55-55-55-FF-FF 1000000000000000000 00-00-64-A7-B3-B6-E0-0D -1000000000000000000 00-00-9C-58-4C-49-1F-F2 -9223372036854775808 00-00-00-00-00-00-00-80 9223372036854775807 FF-FF-FF-FF-FF-FF-FF-7F*/資料參考來源: MSDN BitConverter 類別
沒有留言:
張貼留言