NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Compiler Error CS0233

sizeof can only be used in an unsafe context (consider using System.Runtime.InteropServices.Marshal.SizeOf)

The sizeof operator can only be used in an unsafe block.

The following sample generates CS0233:

using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential)]
public struct S {
   public int a;
}

public class MyClass {
   public static void Main() {
      S myS = new S();
      Console.WriteLine(sizeof(myS));   // CS0233
      // try the following line instead
      // Console.WriteLine(Marshal.SizeOf(myS));
   }
}