search

Google
 

Tuesday, March 11, 2008

Access Specifiers in .net

The main purpose of using access specifiers is to provide security to the applications. The availability (scope) of the member objects of a class may be controlled using access specifiers.


PUBLIC

As the name specifies, it can be accessed from anywhere. If a member of a class is defined as public then it can be accessed anywhere in the class as well as outside the class. This means that objects can access and modify public fields, properties, methods.


PRIVATE

As the name suggests, it can't be accessed outside the class. Its the private property of the class and can be accessed only by the members of the class.


INTERNAL

Friend & Internal mean the same. Internal is used in C#. Friends can be accessed by all classes within an assembly but not from outside the assembly.


PROTECTED

Protected variables can be used within the class as well as the classes that inherites this class.


PROTECTED INTERNAL

The Protected Internal can be accessed by Members of the Assembly or the inheriting class, and ofcourse, within the class itself.

Execution process in .net

.NET applications aren’t executed the same way as the traditional Windows applications you might be used to creating.

Instead of being compiled into an executable containing native code, .NET application code is compiled into Microsoft intermediate language (MSIL) and stored in a file called an assembly.

At run time, the assembly is compiled to its final state by the CLR.

While running, the CLR provides memory management, type-safety checks, and other run-time tasks for the application.

Applications that run under the CLR are called managed code because the CLR takes care of many of the tasks that would have formerly been handled in the application’s executable itself.

Types of Applications in .net

There are four types

Web applications

These applications provide content from a server to client machines over the Internet. Users view the Web application through a Web browser.


Web services

These components provide processing services from a server to other applications over the Internet.


Internet-enabled applications

These are stand-alone applications that incorporate aspects of the Internet to provide online registration, Help, updates, or other services to the user over the Internet.


Peer-to-peer applications

These are stand-alone applications that use the Internet to communicate with other users running their own instances of the application.