Switch to unsafe class automatically when writing unsafe code using [C# Program]?

When using [C# Program] mode, write following code:

int* p = null;

void Main()

Note p is a class member, this is not allowed currently:

There is no option to automatically/manually switch to unsafe mode in C# Program.

This is related to: https://forum.linqpad.net/discussion/comment/4619


  • Options

    How about you do this:

    unsafe int* p = null;

    The alternative would be to have LINQPad add the unsafe modifier to the containing class, either via a query option checkbox or automatically when the compiler encounters CS0214. However, a side-effect of this is that it would essentially prevent you from using await anywhere in your script.

  • Options

    Well, this is something I did not think about, maybe I should just create another class.

Sign In or Register to comment.