I am trying to access a static field of the struct which I already defined as public.
However, I still got “inaccessible due to its protection level” Can anyone help me?
public class Program
{
public struct AT_CMD
{
static int x = 7;
static byte[] cmd_mode = new byte[3] { 0x2B, 0x2B, 0x2B };
static byte[] end_device_assoc = new byte[4] { 0x41, 0x54, 0x41, 0x31 };
//should be 0 for end device, default is 0
static byte[] data_rate = new byte[4] { 0x41, 0x54, 0x42, 0x44 }; //3 for 9600, 5 for 38400
static byte[] channel = new byte[4] { 0x41, 0x54, 0x43, 0x48 }; //0x0B-0x1A
static byte[] Dest_addr_high = new byte[4] { 0x41, 0x54, 0x44, 0x48 }; //0 FOR 16bit
static byte[] Dest_addr_low = new byte[4] { 0x41, 0x54, 0x44, 0x4C };
static byte[] my_addr = new byte[4] { 0x41, 0x54, 0x4D, 0x59 }; // 0-0xFFFF
static byte[] carriage_return = new byte[1] { 0x0D };
}
static void Main()
{
int y = AT_CMD.x;
}
}
By default fields are private. Add the most limiting modifier that will still allow you to work with the structure.