Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7092763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:21:18+00:00 2026-05-28T08:21:18+00:00

I am trying to access a static field of the struct which I already

  • 0

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;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T08:21:19+00:00Added an answer on May 28, 2026 at 8:21 am

    By default fields are private. Add the most limiting modifier that will still allow you to work with the structure.

    public struct AT_CMD
    {
        public static int x = 7;
    }  
    
    static void Main()
    {
        int y = AT_CMD.x;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to access a static method in a Utils class I created: public
How can we access static enum fields using JNI invocation API I am trying
I am trying to access static member of a class. my class is: class
I am trying to figure out how to notify the user which field failed
I am trying to access STATIC Variables from one java class to another but
I am trying to access a static method, but using a variable as the
I am trying to access the value of a textbox and Hidden field from
I'm trying to access a text input that I've already placed on the stage
Trying to access a Servlet from a button on HTML page //Html Page FORM
Am trying to access an API using CURL I can access the API from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.