Asp.
Net
[Link] Net Framework(CLR)
Common Language Runtime (CLR) in C#
The Common Language Runtime (CLR) is a component of the
Microsoft .NET Framework that manages the execution of .NET
applications. It is responsible for loading and executing the code
written in various .NET programming languages, including C#,
[Link], F#, and others.
Working of CLR
1. Compilation and Execution:
When we write a C# program, it gets compiled into
Intermediate Language (IL) code, which is platform-
independent.
The CLR then uses a Just-In-Time (JIT) compiler to convert the IL
code into machine-specific code while the program runs.
2. Services Provided by CLR:
CLR handles automatic memory management through Garbage
Collection, preventing memory leaks.
It ensures that data types are used correctly and safely.
The CLR checks the IL code for security risks before running it.
3. Cross-Language Integration:
CLR allows code from different .NET languages (C#, [Link], F#) to
work together seamlessly through the Common Type System
(CTS).
Key Components of CLR
As the word specify, Common means CLR provides a common
runtime or execution environment as there are more than 60 .NET
programming languages.
Common Language Specification (CLS): It defines common
rules so that code written in different languages can
interoperate.
o Managed Code: The MSIL code which is managed by the
CLR is known as the Managed Code. For managed code
CLR provides three .NET facilities:
o Unmanaged Code: Before .NET development,
programming languages [Link] Components & Win32
API do not generate the MSIL code. So these are not
managed by CLR rather managed by Operating System.
JIT Compiler: It converts IL code into machine code specific to
the system at runtime, optimizing execution.
Garbage Collector: It automatically manages memory by
freeing unused objects, reducing the need for manual memory
management.
Common Type System (CTS): This ensures that different data
types across languages are understood by CLR and can work
together. There are 2 Types of CTS that every .NET
programming language have:
o Value Types: Value Types will store the value directly into
the memory location. These types work with stack
mechanisms only. CLR allows memory for these at
Compile Time.
o Reference Types: Reference Types will contain a memory
address of value because the reference types won’t store
the variable value directly in memory. These types work
with Heap mechanism. CLR allot memory for these at
Runtime.
Benefits of CLR
It optimizes runtime execution and program interaction.
It automatically handles memory allocation and cleanup.
It allows code written in different languages to work together.
Makes it easier to build scalable, multithreaded applications.
Dot Net Framework(FCL):
The Framework Class Library or FCL provides the system functionality
in the .NET Framework as it has various classes, data types,
interfaces, etc. to perform multiple functions and build different
types of applications such as desktop applications, web applications,
mobile applications, etc. The Framework Class Library is integrated
with the Common Language Runtime (CLR) of the .NET framework
and is used by all the .NET languages such as C#, F#, Visual Basic .NET,
etc.
Categories in the Framework Class Library
Details about the Categories in the Framework Class Library are given
as follows:
Utility Features: The utility features in the FCL includes various
collection classes such as list, stack, queue, dictionary, etc. and
also classes for more varied manipulations such as Regex class
for regular expressions.
Wrappers Around OS functionality: Some of the features in the
FCL are wrappers around the underlying Windows OS
functionality. These include the classes for using the file system,
the classes to handle the network features, the classes to
handle I/O for console applications, etc.
Frameworks: There are various frameworks available in the FCL
to develop certain applications. For example, [Link] is used to
develop web applications, Windows Presentation Foundation
(WPF) is used to render user interfaces in Windows
applications, and so on.
Namespaces in the Framework Class Library
Namespaces in the Framework Class Library are a group of related
classes and interfaces that can be used by all the .NET
framework languages. Some of the namespaces in the FCL along with
their description is given as follows:
Namespace Description
The Accessibility namespace is a part
Accessibility of the managed wrapper for the
COM accessibility interface.
The [Link] namespace
[Link] provides support for Windows
Workflow Foundation applications.
[Link] The [Link] namespace has
support for compilation and code
Namespace Description
generation for the C# source code.
The [Link] namespace has
support for compilation and code
[Link]
generation for the JScript source
code.
The [Link] namespace
has support for compilation and code
[Link]
generation for the VisualBasic source
code.
The System namespace has base
classes for definition of interfaces,
System
data types, events, event handlers,
attributes, processing exceptions etc.
The [Link] namespace
handles the creation and working
[Link] with activities in the Window
Workflow Foundation using various
classes.
The [Link] namespace
has multiple standard, specialized,
[Link]
and generic collection objects that
are defined using various types.
Namespace Description
The [Link] namespace
handles configuration data using
[Link] various types. This may include data
in machine or application
configuration files.
The [Link] namespace
accesses and manages data from
[Link]
various sources using different
classes.
The [Link] namespace
handles GDI+ basic graphics
functionality. Various child
[Link]
namespaces also handle vector
graphics functionality, advanced
imaging functionality, etc.
The [Link] namespace
handles language, country, calendars
[Link]
used, format patterns for dates, etc.
using various classes.
The [Link] namespaces support
IO like data read/write into streams,
[Link] data compression, communicate
using named pipes etc. using various
types.
Namespace Description
The [Link] namespace supports
[Link] Language-Integrated Query (LINQ)
using various types.
The [Link] namespace
handles sound files and accessing the
[Link]
sounds provided by the system using
various classes.
The [Link] namespace provides
an interface for network protocols,
[Link] cache policies for web resources,
composing and sending e-mail etc.
using various classes.
The [Link] namespace
gives a managed view of loaded
[Link]
methods, types, fields, etc. It can also
create and invoke types dynamically.
The [Link] namespace has
the .NET security system and
[Link] permissions. Child namespaces
provide authentication,
cryptographic services etc.
[Link] The [Link] namespace
allows multithreaded programming
Namespace Description
using various types.
The XamlGeneratedNamespace has
XamlGeneratedNamespac
compiler-generated types that are
e
not used directly from the code.
5. Key Characteristics of Strings
Immutable: Once created, the content of a string cannot be
altered. Any modification results in the creation of a new string.
Reference Type: Strings are reference types, but they behave
like value types in some scenarios, such as comparison.
Unicode Support: Strings can contain any Unicode character,
allowing support for multiple languages.
Null and Embedded Nulls: Strings can be null and may also
contain embedded null characters (\0).
Operator Overloading: Strings support operator overloading,
such as + for concatenation and == for comparison.