Error del compilador CS0031

El valor constante 'valor' no se puede convertir en un 'tipo'.

Se intentó asignar un valor a una variable cuyo tipo no puede almacenar el valor. Para obtener más información, vea Tipos.

El ejemplo siguiente genera la advertencia CS0031 en contextos checked y unchecked:

// CS0031.cs
namespace CS0031
{
    public class Program
    {
        public static void Main()
        {
            int num = (int)2147483648M; //CS0031
            // Try using a larger numeric type instead.
            // long num = (long)2147483648M; //CS0031

            const decimal d = -10M; // Decimal literal
            unchecked
            {
                const byte b = (byte)d; // CS0031
                // For small values try using a signed byte instead.
                // const sbyte b = (sbyte)d;
            }
        }
    }
}

Consulte también