Compiler Error CS1642
Fixed size buffer fields may only be members of structs.
This error occurs if you use a fixed size buffer field in a class
, instead of a struct
. To resolve this error, change the class
to a struct
or declare the field as an ordinary array.
Example
The following sample generates CS1642.
// CS1642.cs
// compile with: /unsafe /target:library
unsafe class C
{
fixed int a[10]; // CS1642
}
unsafe struct D
{
fixed int a[10];
}
unsafe class E
{
public int[] a = null;
}
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for