This answer was written before the release of C # 7. With C # 7 you can write local methods.
No, you cannot do this. You can create a nested class:
public class ContainingClass { public static class NestedClass { public static void Method2() { } public static void Method3() { } } }
Then you called:
ContainingClass.NestedClass.Method2();
or
ContainingClass.NestedClass.Method3();
I would not recommend this. This is usually a bad idea to have public nested types.
Can you tell us more about what you are trying to achieve? There may be a better approach.
Jon Skeet Nov 15 '11 at 10:44 2011-11-15 10:44
source share