Visual C++ .NET/Data Type/Char
Содержание
Character Fundamental Type
<source lang="csharp">
- 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 );
}
</source>
Character Literals in Action
<source lang="csharp">
- 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 );
}
</source>
Char Literal
<source lang="csharp">
- 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;
}
</source>
Intialize using charater literal
<source lang="csharp">
- include "stdafx.h"
using namespace System; void main() {
char v = "F"; Console::WriteLine( v );
}
</source>
Octal escape
<source lang="csharp">
- include "stdafx.h"
using namespace System; void main() {
char d = "\45"; // octal escape Console::WriteLine ( d );
}
</source>
Unicode escape
<source lang="csharp">
- 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 );
}
</source>
Unicode hexadecimal escape
<source lang="csharp">
- include "stdafx.h"
using namespace System; void main() {
Char e = L"\x0045"; // Unicode hexadecimal escape Console::WriteLine ( e );
}
</source>