forked from dotnet/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbyteschar.cpp
46 lines (40 loc) · 1.26 KB
/
byteschar.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//<Snippet2>
// Example of the BitConverter::GetBytes( __wchar_t ) method.
using namespace System;
// Convert a __wchar_t argument to a byte array and display it.
void GetBytesChar( __wchar_t argument )
{
array<Byte>^byteArray = BitConverter::GetBytes( argument );
Console::WriteLine( "{0,10}{1,16}", argument, BitConverter::ToString( byteArray ) );
}
int main()
{
Console::WriteLine( "This example of the BitConverter::GetBytes( __wchar_t ) "
"\nmethod generates the following output.\n" );
Console::WriteLine( "{0,10}{1,16}", "__wchar_t", "byte array" );
Console::WriteLine( "{0,10}{1,16}", "---------", "----------" );
// Convert __wchar_t values and display the results.
GetBytesChar( L'\0' );
GetBytesChar( L' ' );
GetBytesChar( L'*' );
GetBytesChar( L'3' );
GetBytesChar( L'A' );
GetBytesChar( L'[' );
GetBytesChar( L'a' );
GetBytesChar( L'{' );
}
/*
This example of the BitConverter::GetBytes( __wchar_t )
method generates the following output.
__wchar_t byte array
--------- ----------
00-00
20-00
* 2A-00
3 33-00
A 41-00
[ 5B-00
a 61-00
{ 7B-00
*/
//</Snippet2>