Mega Code Archive

 
Categories / C# / Language Basics
 

Allocates 26 characters on the stack the for loop assigns alphabetic characters to each element

using System; public unsafe class Starter {     public static void Main() {         char* pChar = stackalloc char[26];         char* _pChar = pChar;         for (int count = 0; count < 26; ++count) {             (*_pChar) = (char)(((int)('A')) + count);             ++_pChar;         }         for (int count = 0; count < 26; ++count) {             Console.Write(pChar[count]);         }     } }