using /unsafe

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
 
M

Mohammad

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top