Compiler Error CS0221
Constant value 'value' cannot be converted to a 'type' (use 'unchecked' syntax to override)
An assignment operation that would result in a data loss was detected by checked, which is on by default for constant expressions. Either correct the assignment or use unchecked to resolve this error. For more information, see the checked and unchecked statements article.
The following sample generates CS0221:
// CS0221.cs
public class MyClass
{
public static void Main()
{
// unchecked
// {
int a = (int)0xFFFFFFFF; // CS0221
a++;
// }
}
}
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.
.NET feedback
.NET is an open source project. Select a link to provide feedback: