Why is this Public Function in a Module not accessible
Although the method is Public, the Module (by default) is not. You need to specify this explicitly: Public Module FishTrackerConfigurations
Although the method is Public, the Module (by default) is not. You need to specify this explicitly: Public Module FishTrackerConfigurations
It’s effectively protected or internal, not and. It’s accessible both by derived classes and types in the same assembly. It’s a common misconception to think protected internal means accessible only to derived classes in the same assembly.
private means “only visible within the enclosing class”. protected means “only visible within the enclosing class and any subclasses, and also anywhere in the enclosing class’s package”. private, therefore, has no meaning when applied to a top-level class; the same goes for the first part of the definition of protected. The second part of protected … Read more
No. A subclass can always make a method more public. Even if they couldn’t do this with the method you have in your class, they could always write: public void callsMethodIDontWantExposed() { methodIDontWantExposed(); } … so you’d be in the same situation.
You need to specify that you don’t just need the public properties, using the overload accepting BindingFlags: foreach (PropertyInfo property in typeof(TestClass) .GetProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)) { //do something } Add BindingFlags.Static if you want to include static properties. The parameterless overload only returns public properties.
Yes, you just cannot make them top level classes, they must be inner classes public class Outer { protected class Foo { } } This is fine, it means that the only classes allowed to see Foo are sub classes of Outer class X { // ‘Outer.Foo’ is inaccessible due to its protection level private … Read more
what is the right place to do it – in the public, private or protected section of the class? I would put them in the public section. This is because deleting a constructor or an assignment operator is orthogonal to making them private / protected; and when these aren’t deleted, they are public by default. … Read more
Usually protected means only accessible to subclasses or classes in the same package. However here are the rules for constructors from the JLS: 6.6.2.2. Qualified Access to a protected Constructor Let C be the class in which a protected constructor is declared and let S be the innermost class in whose declaration the use of … Read more
Python does not support access protection as C++/Java/C# does. Everything is public. The motto is, “We’re all adults here.” Document your classes, and insist that your collaborators read and follow the documentation. The culture in Python is that names starting with underscores mean, “don’t use these unless you really know you should.” You might choose … Read more
The first answer is basically correct – protected members can be accessed by classes from the same package subclasses of the declaring class from other packages However, there is a little trick: 6.6.2 Details on protected Access A protected member or constructor of an object may be accessed from outside the package in which it … Read more