0

I Know the Difference between Public/Private/Protected/Static and other Formats of class. But It's my Question.Is there any matter with security or Capacity of File for using Public? If is not...Why do not always use Public?

What is The usage?

in Fact i have problem with reflection to other Class which methods are private or protected.

Amin AmiriDarban
  • 2,031
  • 4
  • 24
  • 32

1 Answers1

1

public, protected, internal, protected internal, and private are all access modifiers.

Why do not always use Public?

These keywords, including public are used to restrict access and show "intention" of how they should be used.

If I decide to make a class public, I am stating that this class is reusable and access to it should not be restricted.

On the otherside of that, if I mark a class as private, I am showing my intention that this class should not be used outside of my containing type.

These are two cases.

For more information, here is a reference: MSDN - Accessibility Levels

Khan
  • 17,904
  • 5
  • 47
  • 59