Public
Definition - What does
Public
mean?
Public, in C#, is a keyword used to declare the accessibility of a type and type member such that the access is not limited. It is one of the access modifiers that provides complete visibility to all types and type members.
C# encourages the use of information hiding, which is the fundamental principle of object-oriented language that helps to improve software quality. Hence, a member of a type has private accessibility by default. This only has to be modified when that member has to be accessible by any code in the assembly in which it is declared or another assembly that references the member.
Some of the C# constructs like namespace, members of an interface and members of an enumeration have public accessibility and do not allow any other accessibility. In addition, user-defined types that overload specific operators for providing custom implementation have to declare the overloaded operators as public.
Techopedia explains
Public
Public is the most permissive accessibility out of all the other accessibilities, which include private, protected and internal accessibility. This is because there is no restriction on accessing a public type or type member - it can be used for both instance and static members of a type.
For example, BankAccount class represents the account details of a user and can have a public method, DisplayAccountBalance, so that any other class within the assembly or the assembly referencing the class can call this method to display the balance.
In contrast to C++, public members of a base class can only be public in all their derived classes. In C#, there is no option to specify access modifiers, whether protected or private, during derivation of a class.
While public accessibility is used to access a type or its member from a code in the same assembly or another assembly that references it, internal accessibility can be used to access types from within the assembly.
This definition was written in the context of C#.
Home
Dictionary
Tags
Development
Related Terms
Information Hiding
Private
Protected (C#)
Internal (C#)
Interface (C#)
Access Modifiers
Related Videos
Related Links
Related White Papers
Other Resources
Related Tags
Categories:
.NET
Programming Languages
C Sharp
Development
Recommended For You
close
Computer Programming: From Machine Language to Artificial Intelligence
Read More
ยป
Tweet
Tweet
Popular White Papers
Techopedia Newsletter Sign-Up
Get Techopedia delivered to your inbox!
Term of the Day:
Get a new Techie Term sent to you every business day
Best of Techopedia:
We"ll bring you the best Techie articles each month.
Sign-In
Join Techopedia
Follow Us
Follow Techopedia on Facebook
Follow Techopedia on LinkedIn
Follow Techopedia on Twitter
Add Techopedia on Google Plus
Get Techopedia on RSS
Home
Dictionary
Articles
Tutorials
Newsletters
Development
Networks
Wireless
Support
Linux
Enterprise
Enterprise Apps
Security
CRM
IT Business
IT Careers
IT Management
Trends
Cloud Computing
Mobile computing
Personal Tech
Gaming
Internet
Search Engines
Social Media
World Wide Web
All Topics
Hacking
Online Marketing
Buzzwords and Jargon
Viruses
Operating Systems
Legal
People