1. Introduction to Microsoft .Net Framework
Introduction to .Net Platform
The Microsoft’s .Net platform encompasses a virtual
machine that abstracts away much of the windows API
from development.
It includes a class library with more functionality than
any other created to date, and a development
environment that spans multiple languages. I
t provides an architecture that makes multiple
language integration simple and straightforward.
This is the first development platform designed from
the ground up with Internet in mind.
.Net is designed and intended for highly distributed
software, making Internet functionality and
interoperability easier and more transparent to include
in systems than ever before.
Microsoft has taken many of the best ideas from the
industry, combined with some ideas of their own, and
brought them altogether into one coherent package.
2. Features of .Net Platform
The .NET Framework is an integral Windows
component that supports building and running the
next generation of applications and XML Web services.
The .NET Framework is designed to fulfill the following
objectives:
To provide a consistent object-oriented programming
environment whether object code is stored and
executed locally, executed locally but Internet-
distributed, or executed remotely.
To provide a code-execution environment that
minimizes software deployment and versioning
conflicts.
To provide a code-execution environment that
promotes safe execution of code, including code
created by an unknown or semi-trusted third party.
To provide a code-execution environment that
eliminates the performance problems of scripted or
interpreted environments.
To make the developer experience consistency across
widely varying types of applications, such as
Windows-based applications and Web-based
applications.
3. .NET Framework Class Library
The .NET Framework class library is a collection of
reusable types that tightly integrate with the common
language runtime. The class library is object
oriented, providing types from which your own
managed code can derive functionality. This not only
makes the .NET Framework types easy to use, but
also reduces the time associated with learning new
features of the .NET Framework. In addition, third-
party components can integrate seamlessly with
classes in the .NET Framework.
4. As you would expect from an object-oriented class
library, the .NET Framework types enable you to
accomplish a range of common programming
tasks, including tasks such as string
management, data collection, database
connectivity, and file access. In addition to these
common tasks, the class library includes types that
support a variety of specialized development
scenarios. For example, you can use the .NET
Framework to develop the following types of
applications and services:
5. Console applications.
Windows GUI applications (Windows Forms).
Windows Presentation Foundation (WPF)
applications.
ASP.NET applications.
Web services.
Windows services.
Service-oriented applications using Windows
Communication Foundation (WCF).
Workflow-enabled applications using
Windows Workflow Foundation (WF).
For example, the Windows Forms classes are
a comprehensive set of reusable types that
vastly simplify Windows GUI development.
6. Garbage Collection: The .NET Framework's garbage
collector manages the allocation and release of
memory for your application. Each time you use the
new operator to create an object, the runtime
allocates memory for the object from the managed
heap
7. Stack Walk: This concept is helpful to anyone
interested in building a profiler to examine managed
applications
8. Class Loader: Normally, the Java Virtual Machine
loads classes from the local file system in a platform-
dependent manner. For example, on UNIX
systems, the Virtual Machine loads classes from the
directory defined by the CLASSPATH environment
variable.
9. Assemblies Overview
Assemblies are a fundamental part of
programming with the .NET Framework.
An assembly performs the following
functions:
It contains code that the common
language runtime executes. Microsoft
intermediate language (MSIL) code in a
portable executable (PE) file will not be
executed if it does not have an
associated assembly manifest. Note that
each assembly can have only one entry
point (that is, DllMain, WinMain, or
Main).
It forms a security boundary. An
assembly is the unit at which
permissions are requested and granted.
It forms a type boundary. Every type's
identity includes the name of the
assembly in which it resides. A type
called MyType loaded in the scope of one
assembly is not the same as a type
called MyType loaded in the scope of
another assembly.
10. Benefits of Assemblies
Assemblies are designed to simplify application
deployment and to solve versioning problems that can
occur with component-based applications.
Versioning Problems
Currently two versioning problems occur with Win32
applications:
1. Versioning rules cannot be expressed between
pieces of an application and enforced by the operating
system.
2. There is no way to maintain consistency between
sets of components that are built together and the set
that is present at run time.
11. Introducing C# Programming
The C# language (pronounced as “C Sharp” or “see
Sharp”) is an Object Oriented Programming Language
developed by Microsoft to become a key part of their
.Net software development platform.
The .NET Framework defines a "Common Language
Specification" (CLS), a sort of lingua franca that
ensures seamless interoperability between CLS-
compliant languages and class libraries. For C#
developers, this means that even though C# is a new
language, it has complete access to the same rich
class libraries that are used by seasoned tools such as
Visual Basic .NET and Visual C++ .NET. C# itself does
not include a class library.
The Cornerstone components of .Net Platform:
12. There are four major cornerstone components of .Net
platform as follows:
1. .Net Building Block services such as Passport
2. .Net Compact Framework that runs on devices such
as mobile phones
3. .Net through XML integration
4. .Net infrastructure such as the .Net framework CLR
and .Net framework class libraries and application
developments such as Microsoft Visual Studio.Net
13. Sample Program: This is just a basic program that
illustrates how a C# program looks like.
public class Class1 {
public static void Main() {
System.Console.WriteLine(“ Welcome to C#”);
}
}
Compiling and Executing
The minimum requirements for getting started with C#
programming are:
1. A text editor (like Windows Notepad)
2. The Microsoft .NET Framework
The text editor allows you to type in the C# code that will be
compiled.
14. The syntax for compiling the sample C# program is:
csc.exe <filename>.cs
The name of our C# program is hello.cs.
The syntax for compilation of the above program file is:
csc.exe hello.cs
Defining a Class:
C# is an object-oriented programming language and uses
classes and structs to implement types such as Windows
Forms, user interface controls, and data structures.
A typical C# application consists of classes defined by the
programmer, combined with classes from the .NET
Framework.
15. Customer obj1 = new Customer();
Classes enable you to develop applications using object-
oriented programming (OOP) techniques. Classes are
templates that define objects.
Declaring Classes:
Classes are defined by using the class keyword, as
shown in the following example:
Public class Custormer{
//Fields,properties,methods and events …
}
Creating Objects
A class defines a type of object, but it is not an object
itself. An object is a concrete entity based on a class,
and is sometimes referred to as an instance of a
class.
16. Introducing Data Types:
A Type is how a programming language
classifies different values and expressions.
Since the computer stores all the data
internally in the form of zeros and
ones, the data needs to have a context or
meaning. In order to preserve this
meaning, Types are used in a programming
language.
Since C# is a strongly typed language; every
variable and object used as part of the
programs must have a declared type.
In any programming language, it's critical
that the compiler, the part of the Visual
Studio framework that interprets the code
you write into a language the computer can
understand, fully understands the type of
data you're manipulating in code. For
example, if you ask the compiler to add the
following values, it would get confused:
17. Overview of C# Data Types :
A Data Type can be described as being either:
A built-in numeric type, such as an int or char, or
A user-defined type, such as a class or interface.
An anonymous type, which consists of a set of public
properties encapsulated in a nameless reference type.
Types can also be defined as being either:
Value Types (C# Reference), which store values. These
include the primitive numeric types, enums and structs,
and also nullable versions of these types.
Reference Types (C# Reference), which store
references to the actual data. These include classes,
interfaces, arrays and delegates.