Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int number;
- unsafe
- {
- int* p = &number;
- *p = 0;
- Console.WriteLine("a: {0}", *p);
- increment((int)p);
- increment((int)p);
- increment((int)p);
- Console.WriteLine("a: {0}", *p);
- }
- Console.ReadKey();
- }
- static void increment(int x)
- {
- unsafe
- {
- int* k = (int*)x;
- *k = *k + 1;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment