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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:31:02+00:00 2026-06-04T10:31:02+00:00

Let see at this class: public class Cluster { private List<Point> points; //private field

  • 0

Let see at this class:

    public class Cluster
    {
        private List<Point> points; //private field

        public float ComputeDistanceToOtherClusterCLINK(Cluster cluster)
        {
            var max = 0f;
            foreach (var point in cluster.points) // here points field are accessible
            {
                  .......
            }
            return max;
        }
    }

why I can access private field?

Can I use this feature or may be it is bad practice?

  • 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-06-04T10:31:05+00:00Added an answer on June 4, 2026 at 10:31 am

    When in doubt, check the language specification.

    According to C# language specification, section 3.5.1:

    3.5.1 Declared accessibility

    The declared accessibility of a member can be one of the following:

    • Public, which is selected by including a public modifier in the member declaration. The intuitive meaning of public is “access not limited”.
    • Protected, which is selected by including a protected modifier in the member declaration. The intuitive meaning of protected is “access limited to the containing class or types derived from the containing class”.
      -Internal, which is selected by including an internal modifier in the member declaration. The intuitive meaning of internal is “access limited to this program”.
    • Protected internal (meaning protected or internal), which is selected by including both a protected and an internal modifier in the member declaration. The intuitive meaning of protected internal is “access limited to this program or types derived from the containing class”.
    • Private, which is selected by including a private modifier in the member declaration. The intuitive meaning of private is “access limited to the containing type”.

    As you can see from the last section, all methods of the containing class (in your case, it’s Cluster) have access to the private field points.

    …and no, this is not a bad practice at all: this is precisely the purpose of private fields!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have this MySQL table: OK.. see the type field? Type 0
Let's see if I can describe this properly... I have an abstract class that
Having this model class public class Usuario { #region Atributos private int _intID =
Let's see the following code snippet in Java. public class Main { public static
Let's say I have a class Collection which holds a list of Items. public
Ok, let's imagine I have an object like this: public class User { public
Let's say I have a manager that looks something like this: public class CustomerManager
Let's say I have an entity that looks like this: public class Album() {
Let's say I for example have this class that generates Fibonacci numbers: public class
Let's say you have this Model: //model public class Stuff { public string Name

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.