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?
When in doubt, check the language specification.
According to C# language specification, section 3.5.1:
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 fieldpoints.…and no, this is not a bad practice at all: this is precisely the purpose of private fields!