100% found this document useful (1 vote)
2K views7 pages

5 Semester Bca Dot Net With C#

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 7

5th Semester BCA Dot Net With C#

Chapter 1
Getting started with .NET Framework
Dot Net Framework: basic concepts of .net framework: MSIL, JIT, CLR, CLS, Execution,
Assemblies, and Application Domain. Features of C#, Intermediate language, Meta Data. DOT
NET namespaces. Building C# Applications: Role of the command line complier (csc.exe),
Building a C# application using csc.exe, the command line debugger (cordbg.exe), using the
visual studio .NET IDE & its debugging.

.NET is a framework to develop software applications. It is designed and developed by


Microsoft and the first beta version released in 2000.

It is used to develop applications for web, Windows, phone. Moreover, it provides a broad
range of functionalities and support.

The .Net Framework supports more than 60 programming languages such as C#, F#, VB.NET,
J#, VC++, JScript.NET, APL, COBOL, Perl, Oberon, ML, Pascal, Eiffel, Smalltalk, Python,
Cobra, ADA, etc.

The core components of .NET are:

1. Common Language Runtime (CLR)


2. Framework Class Library (FCL),

CLR:

It is a program execution engine that loads and executes the program. It converts the program
into native code. It acts as an interface between the framework and operating system. It does
exception handling, memory management, and garbage collection. Moreover, it provides
security, type-safety, interoperability, and portability.

.NET Framework Class Library is the collection of classes, namespaces, interfaces and value
types that are used for .NET applications.

CTS and CLS are parts of .NET CLR and are responsible for type safety within the code.

CTS (Common Type System):

1
5th Semester BCA Dot Net With C#

CTS deals with the data type. So here we have several languages and each and every language
has its own data type and one language data type cannot be understandable by other languages
but .NET Framework language can understand all the data types.

For Example

C# has an int data type and VB.NET has Integer data type. Hence a variable declared as an int
in C# and Integer in VB.NET, finally after compilation, uses the same structure Int32 from
CTS.

CLS (Common Language Specification):

CLS stands for Common Language Specification and it is a subset of CTS. It defines a set of
rules and restrictions that every language must follow which runs under the .NET framework.
The languages which follow these set of rules are said to be CLS Compliant. In simple words,
CLS enables cross-language integration or Interoperability.

For Example

If we talk about C# and VB.NET then, in C# every statement must have to end with a
semicolon. it is also called a statement Terminator, but in VB.NET each statement should not
end with a semicolon(;).

So these syntax rules which you have to follow from language to language differ but CLR can
understand all the language Syntax because in .NET each language is converted into MSIL
code after compilation and the MSIL code is language specification of CLR.

MSIL (Microsoft Intermediate Language):

MSIL or simply an IL is an instruction set into which all the .NET programs are compiled.
When we compile a C# program or any other language programs written in CLS- compliant
language, the source code is compiled into MSIL.

Just-In-Time compiler(JIT):

JIT is a part of Common Language Runtime (CLR) in .NET which is responsible for
managing the execution of .NET programs regardless of any .NET programming language. A
language-specific compiler converts the source code to the intermediate language. This
intermediate language is then converted into the machine code by the Just-In-Time (JIT)

2
5th Semester BCA Dot Net With C#

compiler. This machine code is specific to the computer environment that the JIT compiler
runs on.

Code Execution Process:


The Code Execution Process involves the following two stages:

1. Compiler time process.


2. Runtime process.

Compiler time process

1. The .Net framework has one or more language compilers, such as Visual Basic, C#,
Visual C++, JScript, or one of many third-party compilers such as an Eiffel, Perl, or
COBOL compiler.
2. Anyone of the compilers translates your source code into Microsoft Intermediate
Language (MSIL) code.
3. For example, if you are using the C# programming language to develop an application,
when you compile the application, the C# language compiler will convert your source
code into Microsoft Intermediate Language (MSIL) code.

3
5th Semester BCA Dot Net With C#

4. In short, VB.NET, C#, and other language compilers generate MSIL code. (In other
words, compiling translates your source code into MSIL and generates the required
metadata.)
5. Currently "Microsoft Intermediate Language" (MSIL) code is also known as the
"Intermediate Language" (IL) Code or "Common Intermediate Language" (CIL) Code.

Runtime process.

1. The Common Language Runtime (CLR) includes a JIT compiler for converting MSIL
to native code.
2. The JIT Compiler in CLR converts the MSIL code into native machine code that is then
executed by the OS.
3. During the runtime of a program, the "Just in Time" (JIT) compiler of the Common
Language Runtime (CLR) uses the Metadata and converts Microsoft Intermediate
Language (MSIL) into native code.

Assemblies:

▪ Assembly is a compiled output of program which are used for easy deployment of an
application.
▪ Assembly physically exist as DLLs or EXEs
▪ One assembly can contain one or more files
▪ The constituent files can include any file types like image files, text files etc. along with
DLLs or EXEs
▪ When you compile your source code by default the exe/dll generated is actually an
assembly
▪ Unless your code is bundled as assembly it can not be used in any other application
▪ When you talk about version of a component you are actually talking about version of
the assembly to which the component belongs.
▪ Every assembly file contains information about itself. This information is called as
Assembly Manifest.

Types of assemblies:

4
5th Semester BCA Dot Net With C#

▪ Private Assemblies: are accessible by a single application. They reside within the
application folder and are unique by name. They can be directly used by copying and
pasting them to the bin folder.
▪ Shared Assemblies: are shared between multiple applications to ensure reusability.
They are placed in GAC.
▪ Satellite Assemblies: are the assemblies to provide the support for multiple languages
based on different cultures. These are kept in different modules based on the different
categories available.

Microsoft .Net Metadata

Metadata in .Net is binary information which describes the characteristics of a resource. This
information includes description of the Assembly, Data Types and members with their
declarations and implementations, references to other types and members, Security permissions
etc. A module's metadata contains everything that needed to interact with another module.

During the compile time Metadata created with Microsoft Intermediate Language (MSIL) and
stored in a file called a Manifest. Both Metadata and Microsoft Intermediate Language (MSIL)
together wrapped in a Portable Executable (PE) file. During the runtime of a program Just In
Time (JIT) compiler of the Common Language Runtime (CLR) uses the Metadata and converts
Microsoft Intermediate Language (MSIL) into native code. When code is executed, the runtime
loads metadata into memory and references it to discover information about your code's classes,
members, inheritance, and so on.

Intermediate language (IL) is an object-oriented programming language designed to be used


by compilers for the .NET Framework before static or dynamic compilation to machine code.
The IL is used by the .NET Framework to generate machine-independent code as the output of
compilation of the source code written in any .NET programming language.

Namespace:

A namespace is designed for providing a way to keep one set of names separate from another.
The class names declared in one namespace does not conflict with the same class names
declared in another.

5
5th Semester BCA Dot Net With C#

Defining a Namespace
To define a namespace in C#, we will use the namespace keyword followed by the name of
the namespace and curly braces containing the body of the namespace as follows:
namespace name_of_namespace

// Namespace (Nested Namespaces)

// Classes

// Interfaces

// Structures

// Delegates

Example:

// defining the namespace name1

namespace name1

// C1 is the class in the namespace name1

class C1

// class code

Accessing the Members of Namespace


The members of a namespace are accessed by using dot(.) operator. A class in C# is fully
known by its respective namespace.

Syntax:

[namespace_name].[member_name]

6
5th Semester BCA Dot Net With C#

Note:
• Two classes with the same name can be created inside 2 different namespaces in a single
program.
• Inside a namespace, no two classes can have the same name.
• In C#, the full name of the class starts from its namespace name followed
by dot(.) operator and the class name, which is termed as the fully qualified name of the
class.

You might also like