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
 

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

Similar Threads

How does one make VS compile unsafe code 2
Unsafe code 5
Unsafe Compile Errors 6
Generics and unsafe pointers 2
Managed C# to unmanaged DLL 11
Generics in C# 1
PERMISSION_SET = UNSAFE why? 1
unsafe code and array 4

Back
Top