You are on page 1of 14

E166457 DiTEC195-B

Self-studies 10.1
1.What is .Net framework? Prepare a document explaining the architecture of
.Net framework and its components.
The .Net Framework is a software development platform developed by Microsoft for building
and running Windows applications. The .Net framework consists of developer tools,
programming languages, and libraries for building desktop and web applications.
The .Net framework was intended to create applications that run on the Windows platform.
The first version of the .Net framework was released in 2002.
The .Net Framework architecture is a programming model for the .Net platform that provides
an execution environment and integration with various programming languages to facilitate the
development and deployment of various Windows and desktop applications. It consists of class
libraries and reusable components.
The architecture of the .Net Framework is based on the following main components;

1.common language runtime


The “Common Language Infrastructure” or CLI is a platform in .Net architecture on which the
.Net programs are executed.
The CLI has the following key features:
Exception Handling – Exceptions are errors that occur when the application is executed.
Examples of exceptions are:
✓ If an application tries to open a file on the local machine, but the file is not present.
✓ If the application tries to fetch some records from a database, but the connection to the
database is not valid.
Garbage Collection – Garbage collection is the process of removing unwanted resources when
they are no longer required.
Examples of garbage collection are
✓ A File handle is no longer required. If the application has finished all file operations, the
file handle may no longer be needed.
✓ The database connection is no longer required. If the application has finished all
operations on a database, then the database connection may no longer be needed.
Working with Various programming languages –

As noted in an earlier section, a developer can develop an application in various .Net


programming languages.

1
• Language – The first level is the programming language itself the most common ones
are VB.Net and C#.
• Compiler – There is a compiler that will be separate for each programming language. So,
underlying the VB.Net language, there will be a separate VB.Net compiler. Similarly, for
C#, you will have another compiler.
• Common Language Interpreter – This is the final layer in .Net which would be used to
run a .net program developed in any programming language. So, the subsequent
compiler will send the program to the CLI layer to run the .Net application.

2.Class library
The .NET Framework includes several standard class libraries. A class library is a collection of
methods and functions that serve a primary purpose.
For example, I have a class library that contains methods that handle all file-level operations. So
is there a method that can be used to read text from a file? There is also a way to write text to a
file. Most methods are split into System.* or Microsoft.* namespaces. (An asterisk * means a
reference to any method applicable to the System or Microsoft namespace.)
A namespace is a logical separation of methods. We will discuss these namespaces in detail in
the next chapter.

3.Languages
The types of applications that can be built with the .Net framework fall broadly into the following
categories:
WinForms - This is used to develop forms-based applications that run on end-user computers.
Notepad is an example of a client-based application.
ASP.Net - This is used to develop web-based applications that can run in any browser such as
Internet Explorer, Chrome, and Firefox.
Web applications are processed on servers that have Internet Information Services installed.
Internet Information Services (IIS) is a Microsoft component used to run Asp.Net applications.
The execution results are then sent to the client machine and the output is displayed in the
browser.
ADO.Net - This technology is used to develop applications that interact with databases such as
Oracle and Microsoft SQL Server.

2
Microsoft constantly ensures that the .Net framework is compatible with all supported Windows
operating systems.

3.What is a Variable? What are the differences between Value Type Variables and
Reference Type Variables? Study different types of variables available in C#.Net
and prepare a document containing the data type, size of the variable, and the
data range that can be held in these Variable types.

What is a variable?
Variables are containers for storing data values. All variables have a type that determines the
values that can be stored in the variable. C# is a type-safe language, and the C# compiler
ensures that values stored in variables are always of the correct type.
What are the differences between Value Type Variables and Reference Type Variables?
Reference type variables store references to data (objects), while value type variables hold data
directly. A reference type allows two variables to refer to the same object. Therefore,
operations on one variable can affect objects referenced by other variables.
Value type
A data type is a value type if it holds the data within its own memory allocation. Value types
include the following:

• All numeric data types


• Boolean, Char, and Date
• All structures, even if their members are reference types
• Enumerations, since their underlying type is always SByte, Short, Integer, Long, Byte,
UShort, UInteger, or ULong
Reference type
A reference type stores a reference to its data. Reference types include the following:

• String
• All arrays, even if their elements are value types
• Class types, such as Form
• Delegates

3
A class is a reference type. Note that every array is a reference type, even if its members are
value types.

Types of variables
C# is a strongly typed language. This means you have to declare the type of the variable. This
indicates the type of value to store Integer, Float, Decimal, Text, etc.
C# includes some predefined value and reference types. The following table shows the
predefined data types.

Type Size of the variable Data range


byte 8-bit unsigned integer 0 to 255
sbyte 8-bit signed integer -128 to 127
short 16-bit signed integer -32,768 to 32,767
ushort 16-bit unsigned integer 0 to 65,535
int 32-bit signed integer -2,147,483,648
to
2,147,483,647
uint 32-bit unsigned integer 0 to 4,294,967,295
long 64-bit signed integer -9,223,372,036,854,775,808
to
9,223,372,036,854,775,807
ulong 64-bit unsigned integer 0 to
18,446,744,073,709,551,615
float 32-bit single-precision floating point -3.402823e38 to
type 3.402823e38
double 64-bit double-precision floating -1.79769313486232e308 to
point type 1.79769313486232e308
decimal 128-bit decimal type for financial (+ or -)1.0 x 10e-28
and monetary calculations to
7.9 x 10e28
char 16-bit single Unicode character Any valid character, e.g. a,*,
\x0058 (hex), or\u0058
(Unicode)
bool 8-bit logical true/false value True or False
object Base type of all other types
string A sequence of Unicode characters
DateTime Represents date and time 0:00:00am 1/1/01
to
11:59:59pm 12/31/9999

4
4) What is type casting? Write 5 examples to illustrate how it works. You should give code
samples with adequate comments and screen output to illustrate your answer.

Typecasting may be defined as the process of converting the data type of the outcome of any operation
to another data type. It's actually introduced to improve the efficiency of memory management. Type
conversion makes it very easy to convert the data type of a value, but you must ensure that the value you
convert is the correct one. For example, converting a character to an integer may sound strange, but
converting a float value to an integer makes sense.

Example1:

5
Example2:

6
Example3:

7
Example4:

8
Example5:

9
5) What is the role that the Garbage Collector plays in dot.net framework? Illustrate your answer
with code examples and screen outputs to show the scenarios with and without garbage
collection.

Garbage collection is a memory management technique used by the .NET Framework and many other
programming languages. In C#, the garbage collector is responsible for memory management,
automatically releasing memory that is no longer used by your application.

The garbage collector periodically scans your application's memory to determine which objects are still
in use and which are no longer needed. Objects that are no longer in use are marked for garbage
collection, and their memory is automatically freed by the garbage collector.

Example1:

10
Example2:

11
Example3:

12
Example4:

13

You might also like