c# - Private class with Public method? -


here piece of code:

private class myclass {    public static void main()    {     } }          'or'  private class myclass {    public void method()    {     } } 

i know, first 1 not work. , second 1 will.

but why first not working? there specific reason it?

actually looking solution in perspective, thats why made bold. sorry

it meaningful in scenario; have public class someclass, inside want encapsulate functionality relevant someclass. declaring private class (someprivateclass in example) within someclass, shown below.

public class someclass {     private class someprivateclass     {         public void dosomething()         {          }     }      // someclass has access someprivateclass,     // , can access public methods, properties etc } 

this holds true regardless of whether someprivateclass static, or contains public static methods.

i call nested class, , explored in stackoverflow thread.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -