Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
NET
• Object-oriented programming
• Language independence
Compile to a common Intermediate Language
Efficient data access — A set of .NET components, collectively
known as ADO.NET, provides
efficient access to relational databases and a variety of data
sources.
Code sharing
introducing the concept of the assembly, which replaces the
traditional DLL. Assemblies have formal
facilities for versioning, and different versions of assemblies can
exist side by side
Amila Thennakoon (British Computer Socity )
1
The Common Language Runtime
NET Framework is its runtime execution environment, known as the Common Language
Runtime (CLR) or the .NET runtime. Code running under the control of the CLR is often
termed
managed code.
before executed by the CLR, any source code that you develop (in C# or some other
language) needs to be compiled. Compilation occurs in two steps in .NET:
IL
• based on numeric codes rather than text
• which can be quickly translated into native machine code
• platform independence,
• performance improvement,
• language interoperability
Amila Thennakoon (British Computer Socity ) 2
Common Type System
data type problem is solved in .NET using the Common Type System (CTS). The
CTS defines the
predefined data types available in IL so that all languages that target the .NET
Framework can produce
compiled code ultimately based on these types
The Common Language Specification (CLS) works with the CTS to ensure
language interoperability.
Namespaces are the way that .NET avoids name clashes between classes
Initialization of Variables
C# 3.0 introduced a var keyword that can be used to declare implicit types. The purpose of
implicit types is to store any type in a variable.
The following code snippet declares an implicit variable that stores a string.
var name = "Mahesh Chand";
The scope of a variable is the region of code from which the variable can be
accessed.
the scope is
determined by the following rules:
➤➤ A field (also known as a member variable) of a class is in scope for as long as its
containing class is in
scope.
➤➤ A local variable is in scope until a closing brace indicates the end of the block statement or
method in
which it was declared.
➤➤ A local variable that is declared in a for, while, or similar statement is in scope in the body
of that loop.
They must be initialized when they are declared; and after a value has been assigned, it can
never be
overwritten.
➤➤ The value of a constant must be computable at compile time. Therefore, you can’t
initialize a constant
with a value taken from a variable. If you need to do this, you must use a read-only field
(this is
explained in Chapter 3).
➤➤ Constants are always implicitly static. However, notice that you don’t have to (and, in
fact, are not
permitted to) include the staticAmila
modifier in the constant declaration.
Thennakoon (British Computer Socity ) 9
Constants make your programs easier to modify
Ex Tax constant can apply to every where and only modify in one place
Constants help prevent mistakes in your programs
Cant assign another value to constant in anywhere in the programe
These types are stored in different places in memory; value types are stored in an
area known as the stack,
and reference types are stored in an area known as the managed heap.
Copied by reference
Copied by Value
If you want to define your own type as a value type, you should declare it as a struct