Unsafe code in C#



Unsafe : This means pointers are allowed in C# code. If you wish to compile unsafe code then should specify the /unsafe compiler option in the command line(This is not required if you are using Visual Studio.NET).

using System;
class zzz {
public static void Main() {
yyy a = new yyy();
a.abc();
}
}
unsafe class yyy {
unsafe public void abc() {
int *i; //declaring pointer
int j=1;
i = &j; //pointing
Console.WriteLine((int)i);
*i = 10;
Console.WriteLine(j);
}
}

Related posts

  • Pointers in C#
  • New section for C# source code
  • Email extractor in javascript
  • Visual Basic source code for Article extractor
  • C# source code : Print page
  • Applet in Java
  • Access Windows shutdown dialog box


  • Leave a Reply

    You must be logged in to post a comment.