You are on page 1of 9

Introduction

============

Software : It is defined as Collection of Programs.

Softwares are derived in 2 types.

Packages : A software which is Used to achive a specific task.

MS-Office, Databases, Games, ......etc.

Languages : A programming language is an artificial language designed to


communicate With Machine (particularly a computer) Thru Set Of Instructions.

C, C++, Java, VC++, C#.Net,VB.Net......etc.

Languages are classified into 3 types;

1. High Level Languages : These languages are easy to learn And Easy To
Understand.

2. Low Level Languages : These languages are required for developing (Assembly
Language) device driver programming.

3. Middle Level Language : It is a combination of Low Level and High Level


Languages.

Note:

Machine Language (Native Code Language):


----------------------------------------
The format of machine language changes from os to os.
Every OS contains a specific machine language instruction set.
Machine language also called as native code.

ex: The exe file copied from windows os to linux os will not allow program
execution since native code is differed. Hence it is called platform dependent.

Categories Of Programmers
=========================

1. System Programmers : One who writes programs for a given hardware eg. device
drivers

2. Application Programmers : One who programs application used by people for their
requirement.

Note: .Net is Used for application programming but not for System programming.

Important Terms
===============

PLATFORM & FRAMEWORK


--------------------

Platform is an environment for developing and Deploying (executing) application.

Architecture
============
Note:

1. Assembly code is written for hardware.


2. If Assembly code is to be executed on other machine then that machine require
same hardware.

Framework:
==========
It is ready to use collection of classes and interfaces used for developing a
particular type of application.

Introduction To Visual C#.NET


=============================
Visual - Graphics
C# - C Family
NET - Network Enable Technology

C# is simple, modern, general-purpose, object-oriented programming language used to


develop console and window based applications. It can also be used in combination
of ASP.Net to create web applications.

It Is A Product Of Microsoft Introduced In The Year 2002 As .Net 1.0 And Was
Developed by Anders Hejlsberg.

C#.NET is a case sensitive language.

C#.NET is a compiler-based language.

Versions of .NET
================

SNo. .NET Framework Ver Year Of Release


=============================================
1 .NET 1.0 2002
2 .NET 1.1 2003
3 .NET 2.0 2005
4 .NET 3.0 2006
5 .NET 3.5 2007
6 .NET 4.0 2010
7 .NET 4.5 2012
8 .NET 4.5.1 2013
9 .NET 4.5.2 2014
10 .NET 4.6 2015
=============================================

Advantages of .NET Over Java


============================

.NET Application development is easier and faster than �Java�.

.NET provides many built-in components for development whereas in Java, we have to
mostly use third party components.

�Java� is �platform independent�, whereas �.NET� is �platform dependent� i.e. .NET


programs run with 100% execution only on windows os.
C#.Net Is Pure OOPs Language Whereas Java Is Not Pure OOPs Language.

Note:
=====
. To execute .Net Applications we require .Net Framework as Platform Whereas To
Execute Java Applications We Require JRE as Platform.

.Net framework is not available on many OS, but JRE is available on many OS.

.Net Framework is available on different versions of windows OS.

.Net Framework is available for Linux OS and it is called mono.net

In other OS, .net framework is available but there is no 100% implementation. Hence
there is no guarantee that .net application developed on windows OS will provide
same execution and output on other os. For this reason We cannot say .net is
platform independent.

Features of C#.Net
==================

1. Platform Independent.

Architecture Of Platform Independent


====================================

As .DLL (Dynamic Link Library) and .exe files are executable on any OS with
the help of CLR. Hence .net is called as Platform independent.
.DLL and .EXE contains the code in the form of Byte Code (also called as MSIL
Code - Microsoft Intermediate Language).
CLR is a software, Which Contains A Compiler That converts byte code To
machine language(Native Code) And After Translation To Native Code, CLR Executes
That Code.

Architecture of Code Compilation & Execution


============================================

Every language will have its own compiler and when the code is compiled it
provides a common type of output irrespective of OS i.e. MSIL along with meta data.
When soure code gets compiled does not give machine code directly rather
gives intermediate code i.e. MSIL code.
Compiled output of any language in .net is MSIL.
MSIL code in binary format is available in the form of .exe and .dll file
which is referred as PE file (portable, Executable)
JIT compiler(Just In Time) one of the components of CLR is responsible for
compiling the MSIL code to Native Code And That Code gets executed on OS.

Types Of JIT Compilers


======================
1. Normal JIT - This Compiler Will Compile Required MSIL Code At Execution To
Native Code And The Native Code Is Stored In Buffer/Cache. The Converted Native
Code Further Can Be Reused.

2. Pre JIT - This Compiler Will Compile Complete MSIL Code To Native Code.

3. Econo JIT - This Compiler Will Compile Required MSIL Code At Execution To Native
Code But The Code Will Not Be Buffered/Cached For Reuse.
MSIL Code (Byte Code):
======================

i. MSIL instructions are platform independent instructions.


ii. MSIL is an intermediate instruction set which is independent of processor and
hardware.
iii. MSIL binary form is PE file.

PE : (Portable Executable)
==========================
i. It is a microsoft win32 compatible format file for .net applications,
which contains MSIL code and meta data in binary form.
ii. It has the extension .exe or .dll
iii. PE is based on all win32 platform compatible COFF specification i.e.
given by Microsoft (Common Object File Format)

Architecture of Compiler and Assembler


======================================

2. Language Independent.

.Net application logic can be developed in any .net framework compatible


language. Hence .net is called as language Independent.
Today approximate of 70+ languages are supporting .net Framework.

Languages provided by microsoft


===============================
Visual C++,Visual C#, Visual Basic, Visual F#

Third party languages


=====================
Perl.net, Python.net, Pascal.net, APL.net, Cobol.net, Eiffel.net, Haskell.net,
ML.net, Oberon.net,
Small talk.net, PHP.net, J#.net, .....etc.

3. Language Interoperability.

It is a concept of developing a .net application with the help of more than


one .net language.

CLS - Common Language Specification


&
CTS - Common Type System
=====================================================
CLS is an agreement among language designers and class library designers to
use common subset of basic language features that all languages have to follow.
CTS defines how types are declared, used & managed in runtime. It Is Also An
Important Part Of Runtime Which Supports Cross-Platform Integration.

Ex: Data Types Used In C#.Net Differs With The Data Types Used In VB.Net. Hence
When Applications Of These Languages Need To Be Executed Together Then The problem
is solved in .Net Thru CTS.
CTS contains list of data types that are common for both languages Thru which CLR
understands.

VB.NET C#.NET
| |
Integer int
| |
System.Int32 System.Int32
|___________ _________|
CTS
(CLR)

This will allow C# to invoke VB code and vice versa. Hence Language
Interoperability Has Become Possible In .Net.

4. Supports All OOPs concepts.

5. .NET Supports to develop Different Types Of Applications.

6. Supports to work with database programming-ADO.Net

ADO.Net - Connected Model (Managed Provider)


ADO.Net - Disconnected Model (Unmanaged Provider)
ADO.Net - Entity Framework

7. C# Is Strictly Typed Language.

8. Supports to develop background processes with the help of windows services.

9. Supports to develop 3-Tier architecture with the help of distributed


programming.

10. Supports to work with multi threading.

11. Supports to work with WPF (Windows Presentation Foundation)

12. Supports to work with LINQ Programming.

COMMON LANGUAGE RUNTIME (CLR)


=============================

It is responsible for managing the .net code i.e. MSIL code.


CLR software is installed automatically along with .net Software.
CLR related files are copied into
c:\windows\system32 folder.

Components of CLR(Approx. Of 11 to 12 Components)


=================================================
1. JIT Compiler
2. Common Type System (CTS)
3. Automatic Memory Management
4. Garbage Collector
5. Security Manager
6. Class Loader
7. Exception Management......... etc.

Advantages
==========
1. Vastly simplified development
2. Integration of code Written In Various Languages.
3. Code Reuse Thru Implementation Inheritance.
4. Automatic object life time management.

AUTOMATIC MEMORY MANAGEMENT


===========================

1. CLR manages memory for managed code (Code that targets CLR is referred to
managed code)
2. All Memory allocations of objects and buffers are made from a managed heap.
3. Unused objects and buffers are cleaned up automatically by Garbage collector.

BASE CLASS LIBRARIES (BCL)


(OR)
FRAMEWORK CLASS LIBRARIES (FCL)
=====================================================
Learning Curve Of Any Programming Language Is;

"Knowledge on Rules of that language


+
API required to develop the applications".

BCL/FCL -
BCL - Deals With Basic Rules Of C#.NET like string, DateTime, Mathematical
Functions,.....etc.
FCL - Deals With Advanced Rules Of C#.NET

BCL/FCL - It Is Ready To Use Collection Of Various Types Like Classes, Interfaces,


enums, structures, delegates,.....etc. for Developing Our Applications In Various
Framework Compatible Languages.

Architecture Of BCL/FCL
=======================

Rules Of Programming includes;


declaring variables, use of operators, how to work with arrays, writing
functions, how to call functions, .......etc.

Advantages of BCL/FCL
=====================
1. Language independent
2. Completely object oriented
3. Packaged with .net framework in the form of DLL files.

BCL/FCL includes;
=================
Data types, Conversions (Casting, Conversion Methods using "Convert" class,
Parsing, Boxing & unboxing), Formatting

Collections : ArrayList,Hashtable,Stack,Queue,..etc.
Globalization : Cultures, sorting,......etc.
IO streams : Binary and Text streams, Files, Serialization &
DeSerialization
Networking : Http, TCP/IP, Sockets,..etc.
Reflection : Metadata and IL

JIT compiler, NGen.Exe


======================
JIT Compiler
============

CLR compiles IL in Just-In-Time manner. It Translates IL Code To Native Code


Only For Those Instructions Which Are Needed At That Point Of Execution. If
Application Is Designed With Multiple Functions Then The Called Function For
Execution Will Be Compiled To Native Code Before The Execution And The Native Code
stays in memory(buffer/cache) for subsequent calls.

2. Ngen.Exe-API(Native Generator) - It is used for compiling all the MSIL code


available in PE file to Native code. This is done before the code is executed or
during the deployment of PE on target machine. This way even first time execution
of code is fast since it does not need any more runtime compilation. Translated
Native Code By Ngen.exe Is Stored Into GAC(Global Assembly Cache)

Completely Into
Ngen -------------> PE ----------------> GAC
Translates a Special File

Namespace
=========
A namespace is a logical collection of classes and other types with unique
names.
The structure of the namespace is like a tree where all the related classes
are like leafs.
All BCL begin with the namespace System.

Example:

For window based Button (Namespace)

System.windows.Forms.Button

For web based Button (Namespace)

System.web.UI.Webcontrols.Button

System.Data is a namespace provided to work with database;

System.Data.SqlClient -------- For SQL Server


System.Data.OleDb ------- For other databases

Base Class Library Namespaces


=============================

System
Collections Security
Configuration Diagnostics Text
Globalization Threading
IO Runtime
Net Reflection
Data Windows
OracleClient
SqlClient
OleDb

Points to be remembered before writing C# Program


=================================================

Output Statement
================

Console.Write(...) -- Displays output and the cursor remains on same line


Console.WriteLine(...) -- Displays output and transfers the cursor to new line
Note:
1. Solution is a collection of projects. One solution can have many projects and
every project added to the solution can be some language or different language.
2. The Solution file has the extension as .sln
3. A project is a collection of files including source code (.vb/.cs), resources
(.resx) configuration (.config) files etc.
4. The project file has the extension .vbproj or .csproj
5. A project when build (Compilation + linking) generation an exe/dll as output,
which is called PE

DATA TYPES
==========

Based on the data type the size of variable and the format in memory is decided.
Based on the data type the compiler is going to validate expressions making the
language type safe.

Integral Types
--------------
=============================================Data Type Size .net (CTS)
Comments
=============================================byte 1 System.Byte
0-255 (It is unsigned)
sbyte 1 System.SByte -128 to 127 Signed
short 2 System.Int16
ushort 2 System.UInt16
int 4 System.Int32
uint 4 System.UInt32
long 8 System.Int64
ulong 8 System.UInt64
=============================================
Float Types
-----------

float 4 System.Single has upto 8 digits after decimal


double 8 System.Double has upto 16 digits after
decimal
decimal 16 System.Decimal has fixed 28 digits after
decimal and

Other Data Types


----------------

char 2 System.char uses unicode char set


string 4 System.String uses unicode char set
bool 1 System.Boolean
object System.Object Generic Data Type

Note: All the above data types are value types except string and object are
===== of reference types.

Memory in an Application is divided into 3 parts


================================================

1. Global Memory -- Used by all global variables. These variables are allocated
when the application begins and will remain in memory through out the life of
application.

2. Stack Memory -- Used by local variables of a method, when a method is invoked a


stack of memory is allocated and the stack is cleared when the control Comes Out Of
That Method.

3. Heap Memory -- All dynamic memory requirements of an application are fullfilled


from the heap memory. After allocating some memory from heap to a variable, once
its job is completed the memory must be returned back to heap so that the same can
be reused for other variables. Default size of heap is 1MB.

Declaring Local Variables:


==========================

Reference Type And Value Type


=============================

1) The value type of variable has value whereas the value of a reference type is
reference to value (object) on heap.

2) The value (object) of a reference type is always allocated heap memory.

3) Value types are allocated memory based on the scope of a variable. It it is


global variable its memory is allocated in global memory area. It it is local
variable or parameter memory on stack and if it is a member of an object its memory
is allocated on heap.

VALUE TYPES - directly holds the value.


Example : All basic types, structures, enum,...etc.

REFERENCE TYPES - hold the reference to the value on Heap.


Example : String, Object, Class, Arrays, Delegates

You might also like