Visual C++ .NET/Data Type/Char

Материал из .Net Framework эксперт
Перейти к: навигация, поиск

Character Fundamental Type

<source lang="csharp">

  1. 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">

  1. 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">

  1. include "stdafx.h"
  2. 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">

  1. include "stdafx.h"

using namespace System; void main() {

   char    v = "F";              
   Console::WriteLine( v );  

}

 </source>


Octal escape

<source lang="csharp">

  1. include "stdafx.h"

using namespace System; void main() {

   char d = "\45";      // octal escape
   Console::WriteLine ( d );

}

 </source>


Unicode escape

<source lang="csharp">

  1. 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">

  1. include "stdafx.h"

using namespace System; void main() {

   Char e = L"\x0045";  // Unicode hexadecimal escape
   Console::WriteLine ( e );

}

 </source>