Private.` A private method cannot be called from outside its class. It can be called only from other class methods—this promotes information hiding.`Some advantages.` Programs become easier to maintain and test. Private is the default accessibility. When we specify no other access modifier, a member is private.`An example.` This program declares two classes, one containing private methods and one containing Main. It shows how the private modifier on a method affects how the method can be invoked. `The program calls private methods from inside public method bodies. It shows instance methods and a private static method.`Static Method `static`Notes, above program.` The Test class has four method declarations: two private methods and two public methods. From the Program class, you can only access the public methods. `Public `public`Notes, continued.` The program also invokes a private method from inside a public method. Private accessibility only affects how external sources can access the class. `The accessibility of a public method is not transitive through the public method invocation.`The private accessibility is lexically based—it affects the members based on the position in the source text and type hierarchy.`Accessibility.` The private modifier is part of the grammar of the C# language specification. It can be specified on many different parts of the syntax. `In many programs, using the accessibility modifier on a member as the first modifier in the source text is desirable.`Note 2: `This makes the accessibility more discoverable. As always, please adhere to any existing project guidelines.`Implicit private.` The C# language automatically considers methods to be both instance methods (not static) and private methods (not public). The private keyword is implicit on all methods. `You can only change that by specifying another accessibility such as public or protected.`You can sometimes specify private to emphasize that the method should not be public.`The system adopted by the C# language reduces the symmetry in the source text of programs.`A summary.` We used methods that are private. These can be invoked from other class hierarchies. Accessibility is not transitive but is instead based on lexical scope.`This means` that a private method can be called from a public method body. Private is implicitly added to all methods that do not declare an alternative modifier.

EAOIROOADAQAbAJTestO{OERA2R AiCompute1()OE{OEEAK 1;R A{Private instance mAg that computes something.OER}OOEABAiCompute2()OE{OEEAK this.Compute1()A}1;R A{Public instance mAg.OER}OOERA2R A?AiCompute3()OE{OEEAK 3;R A{Private A?mAg that computes.OER}OOEABA?AiCompute4()OE{OEEAK Compute3()A}1;R A{Public A?mAg.OER}O}OOAJAAO{OEA%E{ROEEA{CA_ Aqinstance of the Test class.OEEA9You can only call the Compute2 ABinstance mAg.OEERTest testAyAqTest();OEEA'test.Compute2());ROEEA{Call the ABA?mAg.OEEA9You cannot access the A2 A?mAg.OEERA'Test.Compute4());OE}O}OOROO2O4R

!_private methods