Visual C++ .NET/Data Type/Char
Содержание
Character Fundamental Type
#include "stdafx.h"
using namespace System;
void main()
{
Char a = L"A"; // character literal "A"
Char b = L"\x0041"; // hex notation for hex 41 ("A")
Console::WriteLine ( a );
Console::WriteLine ( b );
}
Character Literals in Action
#include "stdafx.h"
using namespace System;
void main()
{
char a = "a";
Char b = L"b"; // Unicode "b"
char t = "\t";
Char s = L"\\";
Console::WriteLine ( a );
Console::WriteLine ( b );
Console::WriteLine ( t );
Console::WriteLine ( s );
}
Char Literal
#include "stdafx.h"
#using <mscorlib.dll>
using namespace System;
Int32 main(void)
{
Byte a = "a"; // character "a"
Char b = L"b"; // Unicode "b"
Byte t = "\t"; // tab escape
Char s = L"\\"; // Unicode backslash escape
Byte d = "\45"; // octal escape
Char e = L"\x0045"; // Unicode hexadecimal escape
Console::WriteLine ( a );
Console::WriteLine ( b );
Console::WriteLine ( t );
Console::WriteLine ( s );
Console::WriteLine ( d );
Console::WriteLine ( e );
return 0;
}
Intialize using charater literal
#include "stdafx.h"
using namespace System;
void main()
{
char v = "F";
Console::WriteLine( v );
}
Octal escape
#include "stdafx.h"
using namespace System;
void main()
{
char d = "\45"; // octal escape
Console::WriteLine ( d );
}
Unicode escape
#include "stdafx.h"
using namespace System;
void main()
{
char a = "a";
Char b = L"b"; // Unicode "b"
char t = "\t";
Char s = L"\\";
Console::WriteLine ( a );
Console::WriteLine ( b );
Console::WriteLine ( t );
Console::WriteLine ( s );
}
Unicode hexadecimal escape
#include "stdafx.h"
using namespace System;
void main()
{
Char e = L"\x0045"; // Unicode hexadecimal escape
Console::WriteLine ( e );
}