using /unsafe

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

In my C# program I have a function that uses pointers. Is there a way to
tell the compiler to compile only this function with the unsafe switch and
compile the remaining project as safe code?
I enclosed the body of the function in unsafe block like this:

public static void Foo()
{
unsafe
{
// do nasty things with pointers here
}
}

but I still have to specify the /unsafe switch for the whole project. Is it
possible to compile it with unsafe for part of the code only?

Thanks
 
The /unsafe compiler option only _allows_ unsafe blocks in your code,
it doesn't make all your code unsafe. Code outside unsafe blocks will
compile normally.
 
Back
Top