You haven't shown where you have placed the
Add
line. If it's directly within the class, that's not allowed - code must be within a method.
If you want a static list initialized with a single item, you can use a collection initializer:
public static readonly List<device_DTO> deviceList = new List<device_DTO>
{
new device_DTO
{
DeviceTypeId = 33,
DeviceTypeName = "BPD",
Product = "Very Good Meter",
DeviceClass = "Battery Powered Device",
Form = "2S",
HardwareVersion = "HW V3"
}
};
However, you need to check how you are using the list to decide whether a
static
variable is the correct choice here.