Unsafe code

  • Thread starter Thread starter Jon Milner
  • Start date Start date
J

Jon Milner

How do I declare that my code is unsafe? Sorry the help
files at my University have not been installed!
 
: How do I declare that my code is unsafe? Sorry the help
: files at my University have not been installed!


Rigth click the project > properties > configuration properties > build >
"allow unsafe code block"

Set it to true. Also, your code has to be wrapped in an unsafe block.

HTH
 
Hi Jon,

You can use unsafe blocks inside your methods as
unsafe
{
.....
}

Or you can mark a methods or entire class as unsafe

unsafe class Foo
{
//All methods in the class are unsafe
}

or

public unsafe void DoSomethingUnsafe(...)
{
.....
}

Don't foreget to compile with */unsafe* option set. If you use VS .NET right
click on the project node in the "Solution Explorer" then chose "Properties"
and then in "Configuration Properties | Build" section set "Allow Unsafe
Code Blocks" to true.

BTW if you don't have help installed, but you have internet access you can
use MSDN online msdn.microsoft.com.

HTH
B\rgds
100
 
Ron Vecchi said:
Just browsiung the posts...
What is unsafe code?

Hi Ron,

If you want to work with pointers, you would wrap that code in an unsafe
code block. The code may in fact be safe, but the CLR can't verify it.

Joe
 
Back
Top