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 4115146
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:32:40+00:00 2026-05-20T22:32:40+00:00

I get a "’A.Test.That.Fails’ is inaccessible due to its protection level" error on the

  • 0

I get a "’A.Test.That.Fails’ is inaccessible due to its protection level" error on the following code snippet and I fail to understand the reason.

namespace A
{
    class Test
    {
        public void Demo()
        {
            That[] it = new That[42];
            it[0].fails = 21;
        }

        public struct That
        {
            int fails;
        }
    }
}

Coming from C++ programming and having read that protection rules are almost the same, since there is a single class I would expect it to work even if both the That struct and the Demo method were private.

As the side note, a link to some page summing up scope and protection rules toward the C++ programmer would be greatly appreciated.

  • 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-20T22:32:41+00:00Added an answer on May 20, 2026 at 10:32 pm

    The other answers given already have your answer, so I won’t beat a dead horse here. You need to declare the field public in order to be able to access it from external code.

    In C++, structs and classes are equivalent, with the only difference being the default access level of their respective members.

    However, that’s not the case in C#. Generally, you should only use a struct for small, short-lived objects that are immutable (won’t change). A structure has value type semantics, where as a class has reference type semantics. It’s very important that you understand the difference between value types and reference types if you’re learning to program in C#. Jon Skeet has published an article that attempts to provide that explanation. But you’ll definitely want to pick up a good introductory book to C# that treats these issues in more detail.

    More often than not, you’ll want to use a class in C#, rather than a structure. And when you use that class, note that Microsoft’s design guidelines for C# tend to recommend against exposing public fields. Instead, they recommend that you use a public property, backed by a private field. A more thorough exposition of the rationale behind that guideline is given here. For example:

    class TimePeriod
    {
        private double seconds;
    
        public double Seconds
        {
            get { return seconds; }
            set { seconds = value; }
        }
    }
    

    Or you can use the simpler “automatic properties” syntax, which has the compiler automatically generate that private backing field:

    class TimePeriod
    {
        public double Seconds { get; set; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code var test; $.ajax({ type: "GET", url: "../views/person/controller.php?actor=person&action=checkAge", data: "age="
I get the following error when running mongo-hadoop streaming: java.io.IOException: Cannot run program "mapper.py":
With the following form <form target="dialogiframe" action="ConfigUpdate.cvx" id="TestForm" name="TestForm" method="get"> <input name="test" type="text" size="40"
Why do I get a syntax error from print "Hello World" in Python 3.2?
In Visual Studio 2010 Pro, I get a compile error stating "expected an identifier"
Can you please help me how to convert the following code to using "in"
I'm trying to get the code below working so that it will call a
whenever i try to run something like the following, firebug tells me that "markers
It's familiar to me, that pressing back key will cause activity to get "destroyed",
I have the following xml code in a document called note.xml <?xml version="1.0" encoding="ISO-8859-1"?>

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.