• Profile
  • Resume
  • Portfolio
  • Blog
Avatar

Nelson Silva

A human. Being. Coffee lover.

Blog

I Write My Thoughts Here

Access Modifiers in C#

December 22, 2021 C#

In this post, you will learn how to work with access modifiers so that you can use that same knowledge and thus evolve.

  • access modifiers are used to specify the declared accessibility of a variable (attribute), function (method), class, etc;
  • there are five access modifiers (accessibility levels): public, protected, internal, protected internal and private;
  • public ensures that access is not restricted to any part of our code;
  • protected boils down to the possibility of access only within the class itself or within a class derived from it;
  • the internal makes only if it is possible to have access inside the current namespace;
  • protected internal means that you only have access to the current namespace and classes derived from another namespace;
  • private means access only within the class itself.
using System;

namespace Base {
  class AccessModifiers {
    // public, protected, internal, protected internal and private
    private void Run() {
      Console.WriteLine("We are trying to learn how to work with the various access modifiers.");
    }
  }
}

Don’t forget to watch the video and you can always read this post in Portuguese.

Happy coding!

Previous Next

Categories

  • Announcements
  • Python
  • C#
  • Java
  • Go

Latest Posts

  • for Loop in Go
    May 5, 2022
  • Switch in Go
    May 4, 2022
  • Comparison Operators in Go
    May 3, 2022
+351913416022
contact@nelsonsilvadev.com
Porto, Portugal
Nelson Silva © 2022 All Rights Reserved