allocates 26 characters on the stack the for loop assigns alphabetic characters to each element : stackalloc : Language Basics C# Source Code


Custom Search

C# Source Code » Language Basics » stackalloc »

 

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]);
        }
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Language Basics
» stackalloc