Compiler Error CS0214
Pointers and fixed size buffers may only be used in an unsafe context
Pointers can only be used with the unsafe keyword. For more information, see Unsafe Code and Pointers.
The following sample generates CS0214:
// CS0214.cs
// compile with: /target:library /unsafe
public struct S
{
public int a;
}
public class MyClass
{
public static void Test()
{
S s = new S();
S * s2 = &s; // CS0214
s2->a = 3; // CS0214
s.a = 0;
}
// OK
unsafe public static void Test2()
{
S s = new S();
S * s2 = &s;
s2->a = 3;
s.a = 0;
}
}
Bekerjasama dengan kami di GitHub
Sumber untuk kandungan ini boleh didapati di GitHub, di mana anda juga boleh mencipta dan menyemak isu dan menarik permintaan. Untuk maklumat lanjut, lihat panduan penyumbang kami.
.NET maklum balas
.NET ialah projek sumber terbuka. Pilih pautan untuk memberikan maklum balas: