#315 – Accessibility of Static Methods and Properties

Like instance methods and properties, you can define the accessibility of static methods and properties using access modifiers.  As with instance members, access modifiers on static members indicates what code has access to the member.

  • public – All code has access
  • private – Only code in the defining class has access
  • protected – Code in the defining class or derived classes has access
  • internal – All code in the defining assembly has access
  • protected internal – Code in the defining assembly or in derived classes has access
        // All code has access
        public static Dog MakeNewDog()

        // Only this class has access
        private static void InitSomeStaticData()

        // Subclass has access
        protected static void InitOtherStuff()

        // Code in same assembly has access
        internal static void RunSomeCalcs()

        // Code in same assembly or subclass has access
        protected internal static void DoOtherStuff()

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: