Guest User

Untitled

a guest
Jun 17th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.70 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApplication1
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int number;
  10.  
  11.             unsafe
  12.             {
  13.                 int* p = &number;
  14.  
  15.                 *p = 0;
  16.  
  17.                 Console.WriteLine("a: {0}", *p);
  18.  
  19.                 increment((int)p);
  20.                 increment((int)p);
  21.                 increment((int)p);
  22.  
  23.                 Console.WriteLine("a: {0}", *p);
  24.             }
  25.  
  26.             Console.ReadKey();
  27.         }
  28.  
  29.         static void increment(int x)
  30.         {
  31.             unsafe
  32.             {
  33.                 int* k = (int*)x;
  34.  
  35.                 *k = *k + 1;
  36.             }
  37.         }
  38.     }
  39. }
Add Comment
Please, Sign In to add comment