C# Access Specifiers
These are used to control the visibility of the class
members from outside the world.
They are used to set the scope of the members.
Access Specifiers can be applied for variables, properties
and methods(functions)
Types of Access Specifiers
- private
- protected
- internal
- protected internal
- public
Scope of the Access Specifiers
Access Specifiers
|
Same
namespace(Assembly)
|
OutSide
the namespace(Assembly)
|
||||
Same Class
|
Sub Class
|
Non Sub Class
|
Sub Class
|
Non Sub Class
|
||
private
|
ü
|
X
|
X
|
X
|
X
|
|
protected
|
ü
|
ü
|
X
|
ü
|
X
|
|
internal
|
ü
|
ü
|
ü
|
X
|
X
|
|
protected internal
|
ü
|
ü
|
ü
|
ü
|
X
|
|
public
|
ü
|
ü
|
ü
|
ü
|
ü
|
|
Default access Specifiers
If no access specifiers are mentioned for a class, variable,
property or methods, C# itself assigns access specifiers for these types.
- A class has a default access specifier as internal. A class defined directly in a namespace cannot be explicitly declared as private, protected, or protected internal.
- An enum has a default access specifier as public.
- An interface has a default access specfier as public.
- A struct has a default access specifier as internal.
- A method, field, and property has default access specifier as private.
Syntax:
namespace [name_of_the_namespace]
{
[access_specifier] class
[name_of_the_class]
{
//Variable declaration
[access_specifier] [datatype1] [variable_name1],[variable_name2],[...];
[access_specifier] [datatype2] [variable_name3],[variable_name4],[...];
//method declaration
[access_specifier] [return_type] [name_of_the_function1]([parameters])
{
}
//method declaration
[access_specifier] [return_type] [name_of_the_function2]([parameters])
{
}
}
}
nice article.
ReplyDeleteA method of financing a van instead of buying
ReplyDeleteit outright. The issue which comes up is not knowing about the different van
or car leasing which is available and not getting to use the vehicle because of the cost associated with the monthly payment.
Vehicles are rented on a daily, weekend or weekly rate for
a short period - typically not more than a few weeks.
Here is my homepage Van Leasing
The growth of bacteria is inhibited at these high levels of sugar.
ReplyDeleteIt is for this reason that you should use cranberries along with
any other yeast infection treatments. There are 3 main
symptoms of a yeast infection, the first is itchiness in the
vulva and surrounding areas, it can become so unbearable at times.
my weblog - natural cure for yeast infection
Stretch marks are formed when fibroblasts are somehow restricted and skin vitality is
ReplyDeletenot ok. And also some of the underweight people are also such complaints.
There may be a new and innovative cellulite treatment available now:
cryotherapy.
Also visit my web site Get rid of cellulite
But cellulite can also be a problem for some men, and with
ReplyDeletecertain hormonal conditions it is actually quite common.
It contains natural ingredients like olive oil,
jojoba oil, and other essential oils. You must understand that the
body is designed to move.
Also visit my homepage - Stretch mark removal
There are several service providers that are not genuine.
ReplyDeleteI had a different Youtube account that I was using previously but the reason I created
the new one was because Google and Youtube joined together and I always kept my gmail opened and was unable to
be signed into my gmail and my Youtube account (which used
a yahoo email address) at the same time. Also, economic
growth is unlimited in the world and should not be restricted by worry
about natural resources.
Stop by my web blog ... increase youtube views and ratings