BitConverter.ToString 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 바이트 배열의 각 요소 숫자 값을 해당하는 16진수 문자열 표현으로 변환합니다.
오버로드
ToString(Byte[]) |
지정된 바이트 배열의 각 요소 숫자 값을 해당하는 16진수 문자열 표현으로 변환합니다. |
ToString(Byte[], Int32) |
지정된 바이트 하위 배열의 각 요소 숫자 값을 해당하는 16진수 문자열 표현으로 변환합니다. |
ToString(Byte[], Int32, Int32) |
지정된 바이트 하위 배열의 각 요소 숫자 값을 해당하는 16진수 문자열 표현으로 변환합니다. |
ToString(Byte[])
- Source:
- BitConverter.cs
- Source:
- BitConverter.cs
- Source:
- BitConverter.cs
지정된 바이트 배열의 각 요소 숫자 값을 해당하는 16진수 문자열 표현으로 변환합니다.
public:
static System::String ^ ToString(cli::array <System::Byte> ^ value);
public static string ToString (byte[] value);
static member ToString : byte[] -> string
Public Shared Function ToString (value As Byte()) As String
매개 변수
- value
- Byte[]
바이트 배열입니다.
반환
하이픈으로 구분된 16진수 쌍의 문자열이며 여기에서 각 쌍은 value
;의 해당 요소(예: "7F-2C-4A-00")를 나타냅니다.
예외
value
이(가) null
인 경우
예제
다음 코드 예제에서는 메서드를 Byte 사용하여 배열을 String 개체로 ToString
변환합니다.
// Example of the BitConverter::ToString( unsigned char[ ] ) method.
using namespace System;
// Display a byte array with a name.
void WriteByteArray( array<unsigned char>^bytes, String^ name )
{
String^ underLine = "--------------------------------";
Console::WriteLine( name );
Console::WriteLine( underLine->Substring( 0, Math::Min( name->Length, underLine->Length ) ) );
Console::WriteLine( BitConverter::ToString( bytes ) );
Console::WriteLine();
}
int main()
{
array<unsigned char>^arrayOne = {0,1,2,4,8,16,32,64,128,255};
array<unsigned char>^arrayTwo = {32,0,0,42,0,65,0,125,0,197,0,168,3,41,4,172,32};
array<unsigned char>^arrayThree = {15,0,0,128,16,39,240,216,241,255,127};
array<unsigned char>^arrayFour = {15,0,0,0,0,16,0,255,3,0,0,202,154,59,255,255,255,255,127};
Console::WriteLine( "This example of the "
"BitConverter::ToString( unsigned char[ ] ) \n"
"method generates the following output.\n" );
WriteByteArray( arrayOne, "arrayOne" );
WriteByteArray( arrayTwo, "arrayTwo" );
WriteByteArray( arrayThree, "arrayThree" );
WriteByteArray( arrayFour, "arrayFour" );
}
/*
This example of the BitConverter::ToString( unsigned char[ ] )
method generates the following output.
arrayOne
--------
00-01-02-04-08-10-20-40-80-FF
arrayTwo
--------
20-00-00-2A-00-41-00-7D-00-C5-00-A8-03-29-04-AC-20
arrayThree
----------
0F-00-00-80-10-27-F0-D8-F1-FF-7F
arrayFour
---------
0F-00-00-00-00-10-00-FF-03-00-00-CA-9A-3B-FF-FF-FF-FF-7F
*/
// Example of the BitConverter.ToString( byte[ ] ) method.
using System;
class BytesToStringDemo
{
// Display a byte array with a name.
public static void WriteByteArray( byte[ ] bytes, string name )
{
const string underLine = "--------------------------------";
Console.WriteLine( name );
Console.WriteLine( underLine.Substring( 0,
Math.Min( name.Length, underLine.Length ) ) );
Console.WriteLine( BitConverter.ToString( bytes ) );
Console.WriteLine( );
}
public static void Main( )
{
byte[ ] arrayOne = {
0, 1, 2, 4, 8, 16, 32, 64, 128, 255 };
byte[ ] arrayTwo = {
32, 0, 0, 42, 0, 65, 0, 125, 0, 197,
0, 168, 3, 41, 4, 172, 32 };
byte[ ] arrayThree = {
15, 0, 0, 128, 16, 39, 240, 216, 241, 255,
127 };
byte[ ] arrayFour = {
15, 0, 0, 0, 0, 16, 0, 255, 3, 0,
0, 202, 154, 59, 255, 255, 255, 255, 127 };
Console.WriteLine( "This example of the " +
"BitConverter.ToString( byte[ ] ) \n" +
"method generates the following output.\n" );
WriteByteArray( arrayOne, "arrayOne" );
WriteByteArray( arrayTwo, "arrayTwo" );
WriteByteArray( arrayThree, "arrayThree" );
WriteByteArray( arrayFour, "arrayFour" );
}
}
/*
This example of the BitConverter.ToString( byte[ ] )
method generates the following output.
arrayOne
--------
00-01-02-04-08-10-20-40-80-FF
arrayTwo
--------
20-00-00-2A-00-41-00-7D-00-C5-00-A8-03-29-04-AC-20
arrayThree
----------
0F-00-00-80-10-27-F0-D8-F1-FF-7F
arrayFour
---------
0F-00-00-00-00-10-00-FF-03-00-00-CA-9A-3B-FF-FF-FF-FF-7F
*/
open System
// Display a byte array with a name.
let writeByteArray (bytes: byte[]) (name: string) =
printfn $"{name}"
printfn $"{String('-', name.Length)}"
printfn $"{BitConverter.ToString bytes}\n"
let arrayOne =
[| 0uy; 1uy; 2uy; 4uy; 8uy; 16uy; 32uy; 64uy; 128uy; 255uy |]
let arrayTwo =
[| 32uy; 0uy; 0uy; 42uy; 0uy; 65uy; 0uy; 125uy; 0uy
197uy; 0uy; 168uy; 3uy; 41uy; 4uy; 172uy; 32uy |]
let arrayThree =
[| 15uy; 0uy; 0uy; 128uy; 16uy; 39uy; 240uy; 216uy; 241uy; 255uy; 127uy |]
let arrayFour =
[| 15uy; 0uy; 0uy; 0uy; 0uy; 16uy; 0uy; 255uy; 3uy; 0uy; 0uy; 202uy
154uy; 59uy; 255uy; 255uy; 255uy; 255uy; 127uy |]
printfn "This example of the BitConverter.ToString(byte []) \nmethod generates the following output.\n"
writeByteArray arrayOne "arrayOne"
writeByteArray arrayTwo "arrayTwo"
writeByteArray arrayThree "arrayThree"
writeByteArray arrayFour "arrayFour"
// This example of the BitConverter.ToString( byte[ ] )
// method generates the following output.
//
// arrayOne
// --------
// 00-01-02-04-08-10-20-40-80-FF
//
// arrayTwo
// --------
// 20-00-00-2A-00-41-00-7D-00-C5-00-A8-03-29-04-AC-20
//
// arrayThree
// ----------
// 0F-00-00-80-10-27-F0-D8-F1-FF-7F
//
// arrayFour
// ---------
// 0F-00-00-00-00-10-00-FF-03-00-00-CA-9A-3B-FF-FF-FF-FF-7F
' Example of the BitConverter.ToString( Byte( ) ) method.
Module BytesToStringDemo
' Display a Byte array with a name.
Sub WriteByteArray( bytes( ) As Byte, name As String )
Const underLine As String = "--------------------------------"
Console.WriteLine( name )
Console.WriteLine( underLine.Substring( 0, _
Math.Min( name.Length, underLine.Length ) ) )
Console.WriteLine( BitConverter.ToString( bytes ) )
Console.WriteLine( )
End Sub
Sub Main( )
Dim arrayOne as Byte( ) = { _
0, 1, 2, 4, 8, 16, 32, 64, 128, 255 }
Dim arrayTwo as Byte( ) = { _
32, 0, 0, 42, 0, 65, 0, 125, 0, 197, _
0, 168, 3, 41, 4, 172, 32 }
Dim arrayThree as Byte( ) = { _
15, 0, 0, 128, 16, 39, 240, 216, 241, 255, _
127 }
Dim arrayFour as Byte( ) = { _
15, 0, 0, 0, 0, 16, 0, 255, 3, 0, _
0, 202, 154, 59, 255, 255, 255, 255, 127 }
Console.WriteLine( "This example of the " & _
"BitConverter.ToString( Byte( ) ) " & vbCrLf & _
"method generates the following output." & vbCrLf )
WriteByteArray( arrayOne, "arrayOne" )
WriteByteArray( arrayTwo, "arrayTwo" )
WriteByteArray( arrayThree, "arrayThree" )
WriteByteArray( arrayFour, "arrayFour" )
End Sub
End Module
' This example of the BitConverter.ToString( Byte( ) )
' method generates the following output.
'
' arrayOne
' --------
' 00-01-02-04-08-10-20-40-80-FF
'
' arrayTwo
' --------
' 20-00-00-2A-00-41-00-7D-00-C5-00-A8-03-29-04-AC-20
'
' arrayThree
' ----------
' 0F-00-00-80-10-27-F0-D8-F1-FF-7F
'
' arrayFour
' ---------
' 0F-00-00-00-00-10-00-FF-03-00-00-CA-9A-3B-FF-FF-FF-FF-7F
설명
의 value
모든 요소가 변환됩니다.
적용 대상
ToString(Byte[], Int32)
- Source:
- BitConverter.cs
- Source:
- BitConverter.cs
- Source:
- BitConverter.cs
지정된 바이트 하위 배열의 각 요소 숫자 값을 해당하는 16진수 문자열 표현으로 변환합니다.
public:
static System::String ^ ToString(cli::array <System::Byte> ^ value, int startIndex);
public static string ToString (byte[] value, int startIndex);
static member ToString : byte[] * int -> string
Public Shared Function ToString (value As Byte(), startIndex As Integer) As String
매개 변수
- value
- Byte[]
바이트 배열입니다.
- startIndex
- Int32
value
내의 시작 위치입니다.
반환
하이픈으로 구분된 16진수 쌍의 문자열이며 여기에서 각 쌍은 value
;의 하위 배열에서 해당 요소(예: "7F-2C-4A-00")를 나타냅니다.
예외
value
이(가) null
인 경우
startIndex
가 0보다 작거나 value
- 1의 길이보다 큰 경우
예제
다음 코드 예제에서는 에서 시작 하는 Byte 배열의 부분을 변환 합니다 지정된 startIndex
된 메서드를 ToString
사용 하는 합니다String.
// Example of some BitConverter::ToString( ) method overloads.
using namespace System;
// Display a byte array, using multiple lines if necessary.
void WriteMultiLineByteArray( array<unsigned char>^bytes, String^ name )
{
const int rowSize = 20;
String^ underLine = "--------------------------------";
int iter;
Console::WriteLine( name );
Console::WriteLine( underLine->Substring( 0, Math::Min( name->Length, underLine->Length ) ) );
for ( iter = 0; iter < bytes->Length - rowSize; iter += rowSize )
{
Console::Write( BitConverter::ToString( bytes, iter, rowSize ) );
Console::WriteLine( "-" );
}
Console::WriteLine( BitConverter::ToString( bytes, iter ) );
Console::WriteLine();
}
int main()
{
array<unsigned char>^arrayOne = {0,0,0,0,128,63,0,0,112,65,0,255,127,71,0,0,128,59,0,0,128,47,73,70,131,5,75,6,158,63,77,6,158,63,80,6,158,63,30,55,190,121,255,255,127,255,255,127,127,1,0,0,0,192,255,0,0,128,255,0,0,128,127};
array<unsigned char>^arrayTwo = {255,255,255,0,0,20,0,33,0,0,0,1,0,0,0,100,167,179,182,224,13,0,202,154,59,0,143,91,0,170,170,170,170,170,170,0,0,232,137,4,35,199,138,255,232,244,255,252,205,255,255,129};
array<unsigned char>^arrayThree = {0,222,0,0,0,224,111,64,0,0,224,255,255,255,239,65,0,0,131,0,0,0,112,63,0,143,0,100,0,0,240,61,223,136,30,28,254,116,170,1,250,89,140,66,202,192,243,63,251,89,140,66,202,192,243,63,252,89,140,66,202,192,243,63,82,211,187,188,232,126,255,255,255,244,255,239,127,1,0,0,0,10,17,0,0,248,255,0,88,0,91,0,0,240,255,0,0,240,157};
Console::WriteLine( "This example of the\n"
" BitConverter::ToString( unsigned char[ ], int ) and \n"
" BitConverter::ToString( unsigned char[ ], int, int ) \n"
"methods generates the following output.\n" );
WriteMultiLineByteArray( arrayOne, "arrayOne" );
WriteMultiLineByteArray( arrayTwo, "arrayTwo" );
WriteMultiLineByteArray( arrayThree, "arrayThree" );
}
/*
This example of the
BitConverter::ToString( unsigned char[ ], int ) and
BitConverter::ToString( unsigned char[ ], int, int )
methods generates the following output.
arrayOne
--------
00-00-00-00-80-3F-00-00-70-41-00-FF-7F-47-00-00-80-3B-00-00-
80-2F-49-46-83-05-4B-06-9E-3F-4D-06-9E-3F-50-06-9E-3F-1E-37-
BE-79-FF-FF-7F-FF-FF-7F-7F-01-00-00-00-C0-FF-00-00-80-FF-00-
00-80-7F
arrayTwo
--------
FF-FF-FF-00-00-14-00-21-00-00-00-01-00-00-00-64-A7-B3-B6-E0-
0D-00-CA-9A-3B-00-8F-5B-00-AA-AA-AA-AA-AA-AA-00-00-E8-89-04-
23-C7-8A-FF-E8-F4-FF-FC-CD-FF-FF-81
arrayThree
----------
00-DE-00-00-00-E0-6F-40-00-00-E0-FF-FF-FF-EF-41-00-00-83-00-
00-00-70-3F-00-8F-00-64-00-00-F0-3D-DF-88-1E-1C-FE-74-AA-01-
FA-59-8C-42-CA-C0-F3-3F-FB-59-8C-42-CA-C0-F3-3F-FC-59-8C-42-
CA-C0-F3-3F-52-D3-BB-BC-E8-7E-FF-FF-FF-F4-FF-EF-7F-01-00-00-
00-0A-11-00-00-F8-FF-00-58-00-5B-00-00-F0-FF-00-00-F0-9D
*/
// Example of some BitConverter.ToString( ) method overloads.
using System;
class BytesToStringDemo
{
// Display a byte array, using multiple lines if necessary.
public static void WriteMultiLineByteArray( byte[ ] bytes,
string name )
{
const int rowSize = 20;
const string underLine = "--------------------------------";
int iter;
Console.WriteLine( name );
Console.WriteLine( underLine.Substring( 0,
Math.Min( name.Length, underLine.Length ) ) );
for( iter = 0; iter < bytes.Length - rowSize; iter += rowSize )
{
Console.Write(
BitConverter.ToString( bytes, iter, rowSize ) );
Console.WriteLine( "-" );
}
Console.WriteLine( BitConverter.ToString( bytes, iter ) );
Console.WriteLine( );
}
public static void Main( )
{
byte[ ] arrayOne = {
0, 0, 0, 0, 128, 63, 0, 0, 112, 65,
0, 255, 127, 71, 0, 0, 128, 59, 0, 0,
128, 47, 73, 70, 131, 5, 75, 6, 158, 63,
77, 6, 158, 63, 80, 6, 158, 63, 30, 55,
190, 121, 255, 255, 127, 255, 255, 127, 127, 1,
0, 0, 0, 192, 255, 0, 0, 128, 255, 0,
0, 128, 127 };
byte[ ] arrayTwo = {
255, 255, 255, 0, 0, 20, 0, 33, 0, 0,
0, 1, 0, 0, 0, 100, 167, 179, 182, 224,
13, 0, 202, 154, 59, 0, 143, 91, 0, 170,
170, 170, 170, 170, 170, 0, 0, 232, 137, 4,
35, 199, 138, 255, 232, 244, 255, 252, 205, 255,
255, 129 };
byte[ ] arrayThree = {
0, 222, 0, 0, 0, 224, 111, 64, 0, 0,
224, 255, 255, 255, 239, 65, 0, 0, 131, 0,
0, 0, 112, 63, 0, 143, 0, 100, 0, 0,
240, 61, 223, 136, 30, 28, 254, 116, 170, 1,
250, 89, 140, 66, 202, 192, 243, 63, 251, 89,
140, 66, 202, 192, 243, 63, 252, 89, 140, 66,
202, 192, 243, 63, 82, 211, 187, 188, 232, 126,
255, 255, 255, 244, 255, 239, 127, 1, 0, 0,
0, 10, 17, 0, 0, 248, 255, 0, 88, 0,
91, 0, 0, 240, 255, 0, 0, 240, 157 };
Console.WriteLine( "This example of the\n" +
" BitConverter.ToString( byte[ ], int ) and \n" +
" BitConverter.ToString( byte[ ], int, int ) \n" +
"methods generates the following output.\n" );
WriteMultiLineByteArray( arrayOne, "arrayOne" );
WriteMultiLineByteArray( arrayTwo, "arrayTwo" );
WriteMultiLineByteArray( arrayThree, "arrayThree" );
}
}
/*
This example of the
BitConverter.ToString( byte[ ], int ) and
BitConverter.ToString( byte[ ], int, int )
methods generates the following output.
arrayOne
--------
00-00-00-00-80-3F-00-00-70-41-00-FF-7F-47-00-00-80-3B-00-00-
80-2F-49-46-83-05-4B-06-9E-3F-4D-06-9E-3F-50-06-9E-3F-1E-37-
BE-79-FF-FF-7F-FF-FF-7F-7F-01-00-00-00-C0-FF-00-00-80-FF-00-
00-80-7F
arrayTwo
--------
FF-FF-FF-00-00-14-00-21-00-00-00-01-00-00-00-64-A7-B3-B6-E0-
0D-00-CA-9A-3B-00-8F-5B-00-AA-AA-AA-AA-AA-AA-00-00-E8-89-04-
23-C7-8A-FF-E8-F4-FF-FC-CD-FF-FF-81
arrayThree
----------
00-DE-00-00-00-E0-6F-40-00-00-E0-FF-FF-FF-EF-41-00-00-83-00-
00-00-70-3F-00-8F-00-64-00-00-F0-3D-DF-88-1E-1C-FE-74-AA-01-
FA-59-8C-42-CA-C0-F3-3F-FB-59-8C-42-CA-C0-F3-3F-FC-59-8C-42-
CA-C0-F3-3F-52-D3-BB-BC-E8-7E-FF-FF-FF-F4-FF-EF-7F-01-00-00-
00-0A-11-00-00-F8-FF-00-58-00-5B-00-00-F0-FF-00-00-F0-9D
*/
open System
// Display a byte array, using multiple lines if necessary.
let writeMultiLineByteArray (bytes: byte []) (name: string) =
let rowSize = 20
printfn $"{name}"
printfn $"{String('-', name.Length)}"
let mutable iter = 0
for i in 0 .. rowSize .. (bytes.Length - rowSize - 1) do
printfn $"{BitConverter.ToString(bytes, i, rowSize)}-"
iter <- i
printfn $"{BitConverter.ToString(bytes, iter + rowSize)}\n"
let arrayOne =
[| 0uy; 0uy; 0uy; 0uy; 128uy; 63uy; 0uy; 0uy; 112uy; 65uy
0uy; 255uy; 127uy; 71uy; 0uy; 0uy; 128uy; 59uy; 0uy; 0uy
128uy; 47uy; 73uy; 70uy; 131uy; 5uy; 75uy; 6uy; 158uy; 63uy
77uy; 6uy; 158uy; 63uy; 80uy; 6uy; 158uy; 63uy; 30uy; 55uy
190uy; 121uy; 255uy; 255uy; 127uy; 255uy; 255uy; 127uy; 127uy; 1uy
0uy; 0uy; 0uy; 192uy; 255uy; 0uy; 0uy; 128uy; 255uy; 0uy
0uy; 128uy; 127uy |]
let arrayTwo =
[| 255uy; 255uy; 255uy; 0uy; 0uy; 20uy; 0uy; 33uy; 0uy; 0uy
0uy; 1uy; 0uy; 0uy; 0uy; 100uy; 167uy; 179uy; 182uy; 224uy
13uy; 0uy; 202uy; 154uy; 59uy; 0uy; 143uy; 91uy; 0uy; 170uy
170uy; 170uy; 170uy; 170uy; 170uy; 0uy; 0uy; 232uy; 137uy; 4uy
35uy; 199uy; 138uy; 255uy; 232uy; 244uy; 255uy; 252uy; 205uy; 255uy
255uy; 129uy |]
let arrayThree =
[| 0uy; 222uy; 0uy; 0uy; 0uy; 224uy; 111uy; 64uy; 0uy; 0uy
224uy; 255uy; 255uy; 255uy; 239uy; 65uy; 0uy; 0uy; 131uy; 0uy
0uy; 0uy; 112uy; 63uy; 0uy; 143uy; 0uy; 100uy; 0uy; 0uy
240uy; 61uy; 223uy; 136uy; 30uy; 28uy; 254uy; 116uy; 170uy; 1uy
250uy; 89uy; 140uy; 66uy; 202uy; 192uy; 243uy; 63uy; 251uy; 89uy
140uy; 66uy; 202uy; 192uy; 243uy; 63uy; 252uy; 89uy; 140uy; 66uy
202uy; 192uy; 243uy; 63uy; 82uy; 211uy; 187uy; 188uy; 232uy; 126uy
255uy; 255uy; 255uy; 244uy; 255uy; 239uy; 127uy; 1uy; 0uy; 0uy
0uy; 10uy; 17uy; 0uy; 0uy; 248uy; 255uy; 0uy; 88uy; 0uy
91uy; 0uy; 0uy; 240uy; 255uy; 0uy; 0uy; 240uy; 157uy |]
printfn "This example of the\n BitConverter.ToString(byte [], int) and \n BitConverter.ToString(byte [], int, int) \nmethods generates the following output.\n"
writeMultiLineByteArray arrayOne "arrayOne"
writeMultiLineByteArray arrayTwo "arrayTwo"
writeMultiLineByteArray arrayThree "arrayThree"
// This example of the
// BitConverter.ToString(byte [], int) and
// BitConverter.ToString(byte [], int, int)
// methods generates the following output.
//
// arrayOne
// --------
// 00-00-00-00-80-3F-00-00-70-41-00-FF-7F-47-00-00-80-3B-00-00-
// 80-2F-49-46-83-05-4B-06-9E-3F-4D-06-9E-3F-50-06-9E-3F-1E-37-
// BE-79-FF-FF-7F-FF-FF-7F-7F-01-00-00-00-C0-FF-00-00-80-FF-00-
// 00-80-7F
//
// arrayTwo
// --------
// FF-FF-FF-00-00-14-00-21-00-00-00-01-00-00-00-64-A7-B3-B6-E0-
// 0D-00-CA-9A-3B-00-8F-5B-00-AA-AA-AA-AA-AA-AA-00-00-E8-89-04-
// 23-C7-8A-FF-E8-F4-FF-FC-CD-FF-FF-81
//
// arrayThree
// ----------
// 00-DE-00-00-00-E0-6F-40-00-00-E0-FF-FF-FF-EF-41-00-00-83-00-
// 00-00-70-3F-00-8F-00-64-00-00-F0-3D-DF-88-1E-1C-FE-74-AA-01-
// FA-59-8C-42-CA-C0-F3-3F-FB-59-8C-42-CA-C0-F3-3F-FC-59-8C-42-
// CA-C0-F3-3F-52-D3-BB-BC-E8-7E-FF-FF-FF-F4-FF-EF-7F-01-00-00-
// 00-0A-11-00-00-F8-FF-00-58-00-5B-00-00-F0-FF-00-00-F0-9D
' Example of some BitConverter.ToString( ) method overloads.
Module BytesToStringDemo
' Display a Byte array, using multiple lines if necessary.
Sub WriteMultiLineByteArray( bytes( ) As Byte, name As String )
Const rowSize As Integer = 20
Const underLine As String = "--------------------------------"
Dim iter As Integer
Console.WriteLine( name )
Console.WriteLine( underLine.Substring( 0, _
Math.Min( name.Length, underLine.Length ) ) )
For iter = 0 To bytes.Length - rowSize - 1 Step rowSize
Console.Write( _
BitConverter.ToString( bytes, iter, rowSize ) )
Console.WriteLine( "-" )
Next iter
Console.WriteLine( BitConverter.ToString( bytes, iter ) )
Console.WriteLine( )
End Sub
Sub Main( )
Dim arrayOne as Byte( ) = { _
0, 0, 0, 0, 128, 63, 0, 0, 112, 65, _
0, 255, 127, 71, 0, 0, 128, 59, 0, 0, _
128, 47, 73, 70, 131, 5, 75, 6, 158, 63, _
77, 6, 158, 63, 80, 6, 158, 63, 30, 55, _
190, 121, 255, 255, 127, 255, 255, 127, 127, 1, _
0, 0, 0, 192, 255, 0, 0, 128, 255, 0, _
0, 128, 127 }
Dim arrayTwo as Byte( ) = { _
255, 255, 255, 0, 0, 20, 0, 33, 0, 0, _
0, 1, 0, 0, 0, 100, 167, 179, 182, 224, _
13, 0, 202, 154, 59, 0, 143, 91, 0, 170, _
170, 170, 170, 170, 170, 0, 0, 232, 137, 4, _
35, 199, 138, 255, 232, 244, 255, 252, 205, 255, _
255, 129 }
Dim arrayThree as Byte( ) = { _
0, 222, 0, 0, 0, 224, 111, 64, 0, 0, _
224, 255, 255, 255, 239, 65, 0, 0, 131, 0, _
0, 0, 112, 63, 0, 143, 0, 100, 0, 0, _
240, 61, 223, 136, 30, 28, 254, 116, 170, 1, _
250, 89, 140, 66, 202, 192, 243, 63, 251, 89, _
140, 66, 202, 192, 243, 63, 252, 89, 140, 66, _
202, 192, 243, 63, 82, 211, 187, 188, 232, 126, _
255, 255, 255, 244, 255, 239, 127, 1, 0, 0, _
0, 10, 17, 0, 0, 248, 255, 0, 88, 0, _
91, 0, 0, 240, 255, 0, 0, 240, 157 }
Console.WriteLine( "This example of the" & vbCrLf & _
" BitConverter.ToString( Byte( ), Integer ) and " & _
vbCrLf & " BitConverter.ToString( Byte( ), " & _
"Integer, Integer ) " & vbCrLf & "methods generates " & _
"the following output." & vbCrLf )
WriteMultiLineByteArray( arrayOne, "arrayOne" )
WriteMultiLineByteArray( arrayTwo, "arrayTwo" )
WriteMultiLineByteArray( arrayThree, "arrayThree" )
End Sub
End Module
' This example of the
' BitConverter.ToString( Byte( ), Integer ) and
' BitConverter.ToString( Byte( ), Integer, Integer )
' methods generates the following output.
'
' arrayOne
' --------
' 00-00-00-00-80-3F-00-00-70-41-00-FF-7F-47-00-00-80-3B-00-00-
' 80-2F-49-46-83-05-4B-06-9E-3F-4D-06-9E-3F-50-06-9E-3F-1E-37-
' BE-79-FF-FF-7F-FF-FF-7F-7F-01-00-00-00-C0-FF-00-00-80-FF-00-
' 00-80-7F
'
' arrayTwo
' --------
' FF-FF-FF-00-00-14-00-21-00-00-00-01-00-00-00-64-A7-B3-B6-E0-
' 0D-00-CA-9A-3B-00-8F-5B-00-AA-AA-AA-AA-AA-AA-00-00-E8-89-04-
' 23-C7-8A-FF-E8-F4-FF-FC-CD-FF-FF-81
'
' arrayThree
' ----------
' 00-DE-00-00-00-E0-6F-40-00-00-E0-FF-FF-FF-EF-41-00-00-83-00-
' 00-00-70-3F-00-8F-00-64-00-00-F0-3D-DF-88-1E-1C-FE-74-AA-01-
' FA-59-8C-42-CA-C0-F3-3F-FB-59-8C-42-CA-C0-F3-3F-FC-59-8C-42-
' CA-C0-F3-3F-52-D3-BB-BC-E8-7E-FF-FF-FF-F4-FF-EF-7F-01-00-00-
' 00-0A-11-00-00-F8-FF-00-58-00-5B-00-00-F0-FF-00-00-F0-9D
설명
배열 위치에서 startIndex
배열 끝까지의 요소가 변환됩니다.
적용 대상
ToString(Byte[], Int32, Int32)
- Source:
- BitConverter.cs
- Source:
- BitConverter.cs
- Source:
- BitConverter.cs
지정된 바이트 하위 배열의 각 요소 숫자 값을 해당하는 16진수 문자열 표현으로 변환합니다.
public:
static System::String ^ ToString(cli::array <System::Byte> ^ value, int startIndex, int length);
public static string ToString (byte[] value, int startIndex, int length);
static member ToString : byte[] * int * int -> string
Public Shared Function ToString (value As Byte(), startIndex As Integer, length As Integer) As String
매개 변수
- value
- Byte[]
변환할 바이트를 포함하는 바이트 배열입니다.
- startIndex
- Int32
value
내의 시작 위치입니다.
- length
- Int32
value
의 배열 요소 중에서 변환할 배열 요소의 수입니다.
반환
하이픈으로 구분된 16진수 쌍의 문자열이며 여기에서 각 쌍은 value
;의 하위 배열에서 해당 요소(예: "7F-2C-4A-00")를 나타냅니다.
예외
value
이(가) null
인 경우
startIndex
또는 length
가 0보다 작습니다.
또는
startIndex
가 0보다 크고 value
의 길이보다 크거나 같은 경우
startIndex
와 length
를 합하면 value
내에 위치를 지정할 수 없는 경우. 즉, startIndex
매개 변수가 value
의 길이에서 length
매개 변수를 뺀 값보다 큰 경우입니다.
예제
다음 예제에서는 메서드를 ToString 사용 하 여 바이트 배열의 일부를 변환 하려면 지정 된 startIndex
에서 시작 하 고 지정 된 length
를 문자열로 합니다.
// Example of some BitConverter::ToString( ) method overloads.
using namespace System;
// Display a byte array, using multiple lines if necessary.
void WriteMultiLineByteArray( array<unsigned char>^bytes, String^ name )
{
const int rowSize = 20;
String^ underLine = "--------------------------------";
int iter;
Console::WriteLine( name );
Console::WriteLine( underLine->Substring( 0, Math::Min( name->Length, underLine->Length ) ) );
for ( iter = 0; iter < bytes->Length - rowSize; iter += rowSize )
{
Console::Write( BitConverter::ToString( bytes, iter, rowSize ) );
Console::WriteLine( "-" );
}
Console::WriteLine( BitConverter::ToString( bytes, iter ) );
Console::WriteLine();
}
int main()
{
array<unsigned char>^arrayOne = {0,0,0,0,128,63,0,0,112,65,0,255,127,71,0,0,128,59,0,0,128,47,73,70,131,5,75,6,158,63,77,6,158,63,80,6,158,63,30,55,190,121,255,255,127,255,255,127,127,1,0,0,0,192,255,0,0,128,255,0,0,128,127};
array<unsigned char>^arrayTwo = {255,255,255,0,0,20,0,33,0,0,0,1,0,0,0,100,167,179,182,224,13,0,202,154,59,0,143,91,0,170,170,170,170,170,170,0,0,232,137,4,35,199,138,255,232,244,255,252,205,255,255,129};
array<unsigned char>^arrayThree = {0,222,0,0,0,224,111,64,0,0,224,255,255,255,239,65,0,0,131,0,0,0,112,63,0,143,0,100,0,0,240,61,223,136,30,28,254,116,170,1,250,89,140,66,202,192,243,63,251,89,140,66,202,192,243,63,252,89,140,66,202,192,243,63,82,211,187,188,232,126,255,255,255,244,255,239,127,1,0,0,0,10,17,0,0,248,255,0,88,0,91,0,0,240,255,0,0,240,157};
Console::WriteLine( "This example of the\n"
" BitConverter::ToString( unsigned char[ ], int ) and \n"
" BitConverter::ToString( unsigned char[ ], int, int ) \n"
"methods generates the following output.\n" );
WriteMultiLineByteArray( arrayOne, "arrayOne" );
WriteMultiLineByteArray( arrayTwo, "arrayTwo" );
WriteMultiLineByteArray( arrayThree, "arrayThree" );
}
/*
This example of the
BitConverter::ToString( unsigned char[ ], int ) and
BitConverter::ToString( unsigned char[ ], int, int )
methods generates the following output.
arrayOne
--------
00-00-00-00-80-3F-00-00-70-41-00-FF-7F-47-00-00-80-3B-00-00-
80-2F-49-46-83-05-4B-06-9E-3F-4D-06-9E-3F-50-06-9E-3F-1E-37-
BE-79-FF-FF-7F-FF-FF-7F-7F-01-00-00-00-C0-FF-00-00-80-FF-00-
00-80-7F
arrayTwo
--------
FF-FF-FF-00-00-14-00-21-00-00-00-01-00-00-00-64-A7-B3-B6-E0-
0D-00-CA-9A-3B-00-8F-5B-00-AA-AA-AA-AA-AA-AA-00-00-E8-89-04-
23-C7-8A-FF-E8-F4-FF-FC-CD-FF-FF-81
arrayThree
----------
00-DE-00-00-00-E0-6F-40-00-00-E0-FF-FF-FF-EF-41-00-00-83-00-
00-00-70-3F-00-8F-00-64-00-00-F0-3D-DF-88-1E-1C-FE-74-AA-01-
FA-59-8C-42-CA-C0-F3-3F-FB-59-8C-42-CA-C0-F3-3F-FC-59-8C-42-
CA-C0-F3-3F-52-D3-BB-BC-E8-7E-FF-FF-FF-F4-FF-EF-7F-01-00-00-
00-0A-11-00-00-F8-FF-00-58-00-5B-00-00-F0-FF-00-00-F0-9D
*/
// Example of some BitConverter.ToString( ) method overloads.
using System;
class BytesToStringDemo
{
// Display a byte array, using multiple lines if necessary.
public static void WriteMultiLineByteArray( byte[ ] bytes,
string name )
{
const int rowSize = 20;
const string underLine = "--------------------------------";
int iter;
Console.WriteLine( name );
Console.WriteLine( underLine.Substring( 0,
Math.Min( name.Length, underLine.Length ) ) );
for( iter = 0; iter < bytes.Length - rowSize; iter += rowSize )
{
Console.Write(
BitConverter.ToString( bytes, iter, rowSize ) );
Console.WriteLine( "-" );
}
Console.WriteLine( BitConverter.ToString( bytes, iter ) );
Console.WriteLine( );
}
public static void Main( )
{
byte[ ] arrayOne = {
0, 0, 0, 0, 128, 63, 0, 0, 112, 65,
0, 255, 127, 71, 0, 0, 128, 59, 0, 0,
128, 47, 73, 70, 131, 5, 75, 6, 158, 63,
77, 6, 158, 63, 80, 6, 158, 63, 30, 55,
190, 121, 255, 255, 127, 255, 255, 127, 127, 1,
0, 0, 0, 192, 255, 0, 0, 128, 255, 0,
0, 128, 127 };
byte[ ] arrayTwo = {
255, 255, 255, 0, 0, 20, 0, 33, 0, 0,
0, 1, 0, 0, 0, 100, 167, 179, 182, 224,
13, 0, 202, 154, 59, 0, 143, 91, 0, 170,
170, 170, 170, 170, 170, 0, 0, 232, 137, 4,
35, 199, 138, 255, 232, 244, 255, 252, 205, 255,
255, 129 };
byte[ ] arrayThree = {
0, 222, 0, 0, 0, 224, 111, 64, 0, 0,
224, 255, 255, 255, 239, 65, 0, 0, 131, 0,
0, 0, 112, 63, 0, 143, 0, 100, 0, 0,
240, 61, 223, 136, 30, 28, 254, 116, 170, 1,
250, 89, 140, 66, 202, 192, 243, 63, 251, 89,
140, 66, 202, 192, 243, 63, 252, 89, 140, 66,
202, 192, 243, 63, 82, 211, 187, 188, 232, 126,
255, 255, 255, 244, 255, 239, 127, 1, 0, 0,
0, 10, 17, 0, 0, 248, 255, 0, 88, 0,
91, 0, 0, 240, 255, 0, 0, 240, 157 };
Console.WriteLine( "This example of the\n" +
" BitConverter.ToString( byte[ ], int ) and \n" +
" BitConverter.ToString( byte[ ], int, int ) \n" +
"methods generates the following output.\n" );
WriteMultiLineByteArray( arrayOne, "arrayOne" );
WriteMultiLineByteArray( arrayTwo, "arrayTwo" );
WriteMultiLineByteArray( arrayThree, "arrayThree" );
}
}
/*
This example of the
BitConverter.ToString( byte[ ], int ) and
BitConverter.ToString( byte[ ], int, int )
methods generates the following output.
arrayOne
--------
00-00-00-00-80-3F-00-00-70-41-00-FF-7F-47-00-00-80-3B-00-00-
80-2F-49-46-83-05-4B-06-9E-3F-4D-06-9E-3F-50-06-9E-3F-1E-37-
BE-79-FF-FF-7F-FF-FF-7F-7F-01-00-00-00-C0-FF-00-00-80-FF-00-
00-80-7F
arrayTwo
--------
FF-FF-FF-00-00-14-00-21-00-00-00-01-00-00-00-64-A7-B3-B6-E0-
0D-00-CA-9A-3B-00-8F-5B-00-AA-AA-AA-AA-AA-AA-00-00-E8-89-04-
23-C7-8A-FF-E8-F4-FF-FC-CD-FF-FF-81
arrayThree
----------
00-DE-00-00-00-E0-6F-40-00-00-E0-FF-FF-FF-EF-41-00-00-83-00-
00-00-70-3F-00-8F-00-64-00-00-F0-3D-DF-88-1E-1C-FE-74-AA-01-
FA-59-8C-42-CA-C0-F3-3F-FB-59-8C-42-CA-C0-F3-3F-FC-59-8C-42-
CA-C0-F3-3F-52-D3-BB-BC-E8-7E-FF-FF-FF-F4-FF-EF-7F-01-00-00-
00-0A-11-00-00-F8-FF-00-58-00-5B-00-00-F0-FF-00-00-F0-9D
*/
open System
// Display a byte array, using multiple lines if necessary.
let writeMultiLineByteArray (bytes: byte []) (name: string) =
let rowSize = 20
printfn $"{name}"
printfn $"{String('-', name.Length)}"
let mutable iter = 0
for i in 0 .. rowSize .. (bytes.Length - rowSize - 1) do
printfn $"{BitConverter.ToString(bytes, i, rowSize)}-"
iter <- i
printfn $"{BitConverter.ToString(bytes, iter + rowSize)}\n"
let arrayOne =
[| 0uy; 0uy; 0uy; 0uy; 128uy; 63uy; 0uy; 0uy; 112uy; 65uy
0uy; 255uy; 127uy; 71uy; 0uy; 0uy; 128uy; 59uy; 0uy; 0uy
128uy; 47uy; 73uy; 70uy; 131uy; 5uy; 75uy; 6uy; 158uy; 63uy
77uy; 6uy; 158uy; 63uy; 80uy; 6uy; 158uy; 63uy; 30uy; 55uy
190uy; 121uy; 255uy; 255uy; 127uy; 255uy; 255uy; 127uy; 127uy; 1uy
0uy; 0uy; 0uy; 192uy; 255uy; 0uy; 0uy; 128uy; 255uy; 0uy
0uy; 128uy; 127uy |]
let arrayTwo =
[| 255uy; 255uy; 255uy; 0uy; 0uy; 20uy; 0uy; 33uy; 0uy; 0uy
0uy; 1uy; 0uy; 0uy; 0uy; 100uy; 167uy; 179uy; 182uy; 224uy
13uy; 0uy; 202uy; 154uy; 59uy; 0uy; 143uy; 91uy; 0uy; 170uy
170uy; 170uy; 170uy; 170uy; 170uy; 0uy; 0uy; 232uy; 137uy; 4uy
35uy; 199uy; 138uy; 255uy; 232uy; 244uy; 255uy; 252uy; 205uy; 255uy
255uy; 129uy |]
let arrayThree =
[| 0uy; 222uy; 0uy; 0uy; 0uy; 224uy; 111uy; 64uy; 0uy; 0uy
224uy; 255uy; 255uy; 255uy; 239uy; 65uy; 0uy; 0uy; 131uy; 0uy
0uy; 0uy; 112uy; 63uy; 0uy; 143uy; 0uy; 100uy; 0uy; 0uy
240uy; 61uy; 223uy; 136uy; 30uy; 28uy; 254uy; 116uy; 170uy; 1uy
250uy; 89uy; 140uy; 66uy; 202uy; 192uy; 243uy; 63uy; 251uy; 89uy
140uy; 66uy; 202uy; 192uy; 243uy; 63uy; 252uy; 89uy; 140uy; 66uy
202uy; 192uy; 243uy; 63uy; 82uy; 211uy; 187uy; 188uy; 232uy; 126uy
255uy; 255uy; 255uy; 244uy; 255uy; 239uy; 127uy; 1uy; 0uy; 0uy
0uy; 10uy; 17uy; 0uy; 0uy; 248uy; 255uy; 0uy; 88uy; 0uy
91uy; 0uy; 0uy; 240uy; 255uy; 0uy; 0uy; 240uy; 157uy |]
printfn "This example of the\n BitConverter.ToString(byte [], int) and \n BitConverter.ToString(byte [], int, int) \nmethods generates the following output.\n"
writeMultiLineByteArray arrayOne "arrayOne"
writeMultiLineByteArray arrayTwo "arrayTwo"
writeMultiLineByteArray arrayThree "arrayThree"
// This example of the
// BitConverter.ToString(byte [], int) and
// BitConverter.ToString(byte [], int, int)
// methods generates the following output.
//
// arrayOne
// --------
// 00-00-00-00-80-3F-00-00-70-41-00-FF-7F-47-00-00-80-3B-00-00-
// 80-2F-49-46-83-05-4B-06-9E-3F-4D-06-9E-3F-50-06-9E-3F-1E-37-
// BE-79-FF-FF-7F-FF-FF-7F-7F-01-00-00-00-C0-FF-00-00-80-FF-00-
// 00-80-7F
//
// arrayTwo
// --------
// FF-FF-FF-00-00-14-00-21-00-00-00-01-00-00-00-64-A7-B3-B6-E0-
// 0D-00-CA-9A-3B-00-8F-5B-00-AA-AA-AA-AA-AA-AA-00-00-E8-89-04-
// 23-C7-8A-FF-E8-F4-FF-FC-CD-FF-FF-81
//
// arrayThree
// ----------
// 00-DE-00-00-00-E0-6F-40-00-00-E0-FF-FF-FF-EF-41-00-00-83-00-
// 00-00-70-3F-00-8F-00-64-00-00-F0-3D-DF-88-1E-1C-FE-74-AA-01-
// FA-59-8C-42-CA-C0-F3-3F-FB-59-8C-42-CA-C0-F3-3F-FC-59-8C-42-
// CA-C0-F3-3F-52-D3-BB-BC-E8-7E-FF-FF-FF-F4-FF-EF-7F-01-00-00-
// 00-0A-11-00-00-F8-FF-00-58-00-5B-00-00-F0-FF-00-00-F0-9D
' Example of some BitConverter.ToString( ) method overloads.
Module BytesToStringDemo
' Display a Byte array, using multiple lines if necessary.
Sub WriteMultiLineByteArray( bytes( ) As Byte, name As String )
Const rowSize As Integer = 20
Const underLine As String = "--------------------------------"
Dim iter As Integer
Console.WriteLine( name )
Console.WriteLine( underLine.Substring( 0, _
Math.Min( name.Length, underLine.Length ) ) )
For iter = 0 To bytes.Length - rowSize - 1 Step rowSize
Console.Write( _
BitConverter.ToString( bytes, iter, rowSize ) )
Console.WriteLine( "-" )
Next iter
Console.WriteLine( BitConverter.ToString( bytes, iter ) )
Console.WriteLine( )
End Sub
Sub Main( )
Dim arrayOne as Byte( ) = { _
0, 0, 0, 0, 128, 63, 0, 0, 112, 65, _
0, 255, 127, 71, 0, 0, 128, 59, 0, 0, _
128, 47, 73, 70, 131, 5, 75, 6, 158, 63, _
77, 6, 158, 63, 80, 6, 158, 63, 30, 55, _
190, 121, 255, 255, 127, 255, 255, 127, 127, 1, _
0, 0, 0, 192, 255, 0, 0, 128, 255, 0, _
0, 128, 127 }
Dim arrayTwo as Byte( ) = { _
255, 255, 255, 0, 0, 20, 0, 33, 0, 0, _
0, 1, 0, 0, 0, 100, 167, 179, 182, 224, _
13, 0, 202, 154, 59, 0, 143, 91, 0, 170, _
170, 170, 170, 170, 170, 0, 0, 232, 137, 4, _
35, 199, 138, 255, 232, 244, 255, 252, 205, 255, _
255, 129 }
Dim arrayThree as Byte( ) = { _
0, 222, 0, 0, 0, 224, 111, 64, 0, 0, _
224, 255, 255, 255, 239, 65, 0, 0, 131, 0, _
0, 0, 112, 63, 0, 143, 0, 100, 0, 0, _
240, 61, 223, 136, 30, 28, 254, 116, 170, 1, _
250, 89, 140, 66, 202, 192, 243, 63, 251, 89, _
140, 66, 202, 192, 243, 63, 252, 89, 140, 66, _
202, 192, 243, 63, 82, 211, 187, 188, 232, 126, _
255, 255, 255, 244, 255, 239, 127, 1, 0, 0, _
0, 10, 17, 0, 0, 248, 255, 0, 88, 0, _
91, 0, 0, 240, 255, 0, 0, 240, 157 }
Console.WriteLine( "This example of the" & vbCrLf & _
" BitConverter.ToString( Byte( ), Integer ) and " & _
vbCrLf & " BitConverter.ToString( Byte( ), " & _
"Integer, Integer ) " & vbCrLf & "methods generates " & _
"the following output." & vbCrLf )
WriteMultiLineByteArray( arrayOne, "arrayOne" )
WriteMultiLineByteArray( arrayTwo, "arrayTwo" )
WriteMultiLineByteArray( arrayThree, "arrayThree" )
End Sub
End Module
' This example of the
' BitConverter.ToString( Byte( ), Integer ) and
' BitConverter.ToString( Byte( ), Integer, Integer )
' methods generates the following output.
'
' arrayOne
' --------
' 00-00-00-00-80-3F-00-00-70-41-00-FF-7F-47-00-00-80-3B-00-00-
' 80-2F-49-46-83-05-4B-06-9E-3F-4D-06-9E-3F-50-06-9E-3F-1E-37-
' BE-79-FF-FF-7F-FF-FF-7F-7F-01-00-00-00-C0-FF-00-00-80-FF-00-
' 00-80-7F
'
' arrayTwo
' --------
' FF-FF-FF-00-00-14-00-21-00-00-00-01-00-00-00-64-A7-B3-B6-E0-
' 0D-00-CA-9A-3B-00-8F-5B-00-AA-AA-AA-AA-AA-AA-00-00-E8-89-04-
' 23-C7-8A-FF-E8-F4-FF-FC-CD-FF-FF-81
'
' arrayThree
' ----------
' 00-DE-00-00-00-E0-6F-40-00-00-E0-FF-FF-FF-EF-41-00-00-83-00-
' 00-00-70-3F-00-8F-00-64-00-00-F0-3D-DF-88-1E-1C-FE-74-AA-01-
' FA-59-8C-42-CA-C0-F3-3F-FB-59-8C-42-CA-C0-F3-3F-FC-59-8C-42-
' CA-C0-F3-3F-52-D3-BB-BC-E8-7E-FF-FF-FF-F4-FF-EF-7F-01-00-00-
' 00-0A-11-00-00-F8-FF-00-58-00-5B-00-00-F0-FF-00-00-F0-9D
설명
배열 위치 startIndex
의 length
요소가 변환됩니다. 가 0이면 length
메서드는 를 반환합니다 String.Empty.
적용 대상
.NET