Get a pointer to the start of a string and display the contents of string via pointer : Pointer : Unsafe C# Examples


C# Examples » Unsafe » Pointer »

 

Get a pointer to the start of a string and display the contents of string via pointer









    
using  System;  
  
class  MainClass  {  
    unsafe  public  static  void  Main()  {  
        string  str  =  "this  is  a  test";  
  
        fixed(char*  p  =  str)  {  
            for(int  i=0;  p[i]  !=  0;  i++)  
                Console.Write(p[i]);  
        }  
        Console.WriteLine();  
    }  
}
    
   
  
   



Output

this is a test


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Unsafe
» Pointer