Demonstrate pointers and unsafe : Pointer Unsafe : Language Basics C# Source Code


Custom Search

C# Source Code » Language Basics » Pointer Unsafe »

 

Demonstrate pointers and unsafe









    

/*
C#: The Complete Reference 
by Herbert Schildt 

Publisher: Osborne/McGraw-Hill (March 8, 2002)
ISBN: 0072134852
*/


// Demonstrate pointers and unsafe. 
 
using System; 
 
public class UnsafeCode { 
  // mark Main as unsafe 
  unsafe public static void Main() { 
    int count = 99; 
    int* p; // create an int pointer 
 
    p = &count; // put address of count into p 
 
    Console.WriteLine("Initial value of count is " + *p); 
 
    *p = 10; // assign the to count via p 
     
    Console.WriteLine("New value of count is " + *p); 
  } 
}


           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Language Basics
» Pointer Unsafe