หมายเหตุ
การเข้าถึงหน้านี้ต้องได้รับการอนุญาต คุณสามารถลอง ลงชื่อเข้าใช้หรือเปลี่ยนไดเรกทอรีได้
การเข้าถึงหน้านี้ต้องได้รับการอนุญาต คุณสามารถลองเปลี่ยนไดเรกทอรีได้
'name' is of type 'type'. The type specified in a constant declaration must be sbyte, byte, short, ushort, int, uint, long, ulong, char, float, double, decimal, bool, string, an enum-type, or a reference-type.
The types permitted in a const declaration are limited to those described in this message.
To correct this error
- Declare the constant with an allowed type.
Example
The following code produces CS1959 because null is not a type.
// cs1959.cs
class Program
{
static void Test<T>() where T : class
{
const T x = null; // CS1959
}
}