Professional Documents
Culture Documents
Presented By,: Aditya Ranjan Dutta
Presented By,: Aditya Ranjan Dutta
Presented By,: Aditya Ranjan Dutta
The final version of the SDK 1.0 and Runtime was made
publicly available on 15-Jan-2002.
Garbage Collection.
Client-Server Utility
Resource Technology
Is a platform environment.
.NET Languages:
VB.NET
ASP.NET
C#.NET
C++.NET
J#.NET
Console
Windows Forms
Web Forms
Web Services
VB.NET ASP.NET C# J#
MANGED CODE
M.C M.C M.C M.C M.C
NA TIVE CODE
N.C N.C N.C N.C N.C
Operating System
Memory management.
Exception handling.
Language Interswapping.
The CTS defines the rules by which all types are declared,
defined and managed, regardless of source language.
CLS contains rules that are to be followed for .net frame work
supported languages.
The CLS defines the reasonable subset of the CTS that should
be sufficient to support cross-language integration, and
specifically excludes problem areas such as unsigned integers,
operator overloading, and more.
Type of Assembly:
There are three types of Assembly. They are
• Private Assembly - This type of assembly is used by a
single application. It is stored in the application's directory or
the applications sub-directory. There is no version constraint
in a private assembly.
• Shared Assembly or Public Assembly - A shared
assembly has version constraint. It is stored in the Global
Assembly Cache (GAC). The shared assemblies may be used
by many applications.
• Satellite Assembly - is an assembly that contains only
resources, and no code. The resources are location specific.
A satellite assembly is associated with a main assembly, the
one that actually contains the code.
July 29, 2008 17
GAC Assembly
2. Description of types.
Name, visibility, base class, and interfaces implemented.
Members (methods, fields, properties, events, nested types).
3. Attributes.
Additional descriptive elements that modify types and
Julymembers.
29, 2008 20
Metadata
Benefits of Metadata:
1. Self-describing files
Common language runtime modules and assemblies are self-describing.
A module's metadata contains everything needed to interact with another
module.
Metadata automatically provides the functionality of IDL in COM, allows to use
one file for both definition and implementation.
Runtime modules and assemblies do not even require registration with the
operating system.
The descriptions used by the runtime always reflect the actual code in the
compiled file, which increases application reliability.
3. Attributes
Attributes can be found throughout the .NET Framework and are used to control
in more detail how your program behaves at run time.
July 29, 2008 21
Versioning
.NET maintain one application with more then one version and
also solve DLL HELL problem because it can run same application
with different version at a same time.
Interpreter – Compiler.
Interpreter – Compiler.
1. Multithreading.
2. Networking.
3. Graphics.
4. File Systems.
Program:
#using <mscorlib.dll>
using namespace System;
void main( )
{
Console::WriteLine(L"C++
July 29, 2008 Hello, World!"); 29
}
CLR Executable
#using makes all types accessible from the specified DLL,
similar to a #include directive in C or C++. However, unlike
#include, which imports C or C++ types, #using imports types
for any .NET assembly.
The L that prefixes the literal string tells the C++ compiler to
convert the literal into a Unicode string.
ADO ADO.NET
The ADO Recordset was a huge The ADO.NET object is a light
object in ADO weight object
It provided the ability to support It provided the ability to support
multiple types of cursors multiple types of classes.
It provided fast lightweight ADO.NET DataReader is
"firehose" cursor equivalent to the "firehose"
cursor.
It is a disconnected client-side The DataSet is a disconnected
cursor that supported tracking, cache with tracking and control
optimistic locking, and automatic binding functionality.
batch updates of a database.
all of this functionality was The DataAdapter provides the
difficult to customize. ability to completely customize
July 29, 2008 35
ADO.NET Architecture
DataSet:
The dataset is a disconnected, in-memory representation of
data.
The data in DataSet can be loaded from any valid data source
like Microsoft SQL server database, an Oracle database or from
a Microsoft Access database.
July 29, 2008 37
ADO.NET Architecture
Data Provider:
The Data Provider is responsible for providing and maintaining
the connection to the database.
1. SQL
2. Oracle
3.MS Access
Provider=microsoft.jet.oledb 4.0;
MS Access Microsoft. Jet data source=File location
Because
July 29, 2008 only one row is in memory at a time, the DataReader
44
provides the lowest overhead in terms of system performance.
The DataAdapter Object
The DataAdapter is the class at the core of ADO .NET's
disconnected data access.
WebForm Design:
The data type specifies what type of data the column can hold.
The table below contains the most common data types in SQL:
Data Type Description
int(size) Hold integers only. The maximum number of digits are specified in
parenthesis.
decimal(size,d) Hold numbers with fractions. The maximum number of digits are specified
numeric(size,d) in "size". The maximum number of digits to the right of the decimal is
specified in "d".
char(size) Holds a fixed length string
Alter Table:
The ALTER TABLE statement is used to add or drop columns in an existing table.
The users cannot see the indexes, they are just used to speed
up queries.
DCL SQL statements are more part of the DBMS and have large
differences between the SQL variations.
Query:
Primary Key:
A table can have more than one candidate key, but only one
candidate key can become the primary key for that table.
Foreign Key:
Joins are of three type. They are: Inner Join, Left Join and Right
Join.
Inner Join:
The INNER JOIN returns all rows from both tables where there is
a match.
Syntax:
SELECT field1, field2, field3 FROM first_table LEFT JOIN second_table ON
first_table.keyfield
July 29, 2008 = second_table.foreign_keyfield 60
Joins
Left Join:
The LEFT JOIN returns all the rows from the first table, even if
there are no matches in the second table.
Syntax:
SELECT field1, field2, field3 FROM first_table LEFT JOIN second_table ON
first_table.keyfield = second_table.foreign_keyfield
Right Join:
The RIGHT JOIN returns all the rows from the second table, even
if there are no matches in the first table.
Syntax:
SELECT field1, field2, field3 FROM first_table RIGHT JOIN second_table ON
first_table.keyfield = second_table.foreign_keyfield
Syntax:
SELECT function(column) FROM table
Aggregate Functions:
Function Description
AVG(clmnnam Returns the average value of a column
e)
COUNT(colum Returns the number of rows (without NULL) of a
n)
COUNT(*) column
Returns the number of selected rows
COUNT(DISTIN Returns the number of distinct results
CT column)
FIRST(column) Returns the value of the first record in a specified
LAST(column) field
Returns the value of the last record in a specified
MAX(column) field
Returns the highest value of a column
MIN(column) Returns the lowest value of a column
SUM(column) Returns the total sum of a column
July 29, 2008 63
VB.NET
Textbox
Label
Button
Coding
Coding
Coding
To properly use the ASP files and ASP.NET files you need to
create a virtual Directory for each application.
3. HTML Control
1.1 FTP
1.2 HTTP
1.3 SMTP
Validation Summary:
Validation Summary:
Then go to top of the html Page coding and write the following
coding:
<Script language=“vbScript” runat=“server”>
sub user (s as object,e as ServarValidateEventargs)
If .len(e.value)<8 and .len(e.value)>16
then
e.isvalid=False
else
July 29, 2008
e.isvalid=True 83
End sub
ASP.NET Objects
3. Application Objects
5. Server Objects
7. Session Objects
9. Request Objects
Application Objects:
When we used a particular web form for the first time the first
value we used is stored in the system as cookies with the help
of application object.
Designing:
Coding:
Imports System.IO
Imports System.Data
Sub button1_Click()
Application.add(“Code”,Textbox1.Text)
Response.Write(“The application Object is Created”)
Application.set(“Code”,Textbox1.text)
Response.Write(“Application.get(“Code”))
End Sub
Server Objects:
Webform2 Coding:
Page_load()
If not.IspostBack Then
label1.Text=“You need all the Information”
End If
Webform3 Coding:
Page_load()
If not.IspostBack Then
Response.Write(“Session Created”)
Response.Write(Session.Sessionid)
Response.Write (“Timeout”&Session.Timeout.Tostring())
End If
Eg: In Online exam time for each question is fixed with the help
of Session object
Designing: Webform1
Request Objects:
Request Objects are used for requesting the task from client to
server.
Designing:
Coding:
Page_load()
Dim bc as httpBrowserCapabilities= Request.Browser
Response.Write(“Browser Type of the Server” &bc.Type)
Response.Write(“The Name of the Server” &bc.Name.ToString())
Response.Write(“The VB Script” &bc.vbscript.ToString())
Response.Write(“The Java Script” &bc.Javascript.ToString())
Response.Write(“The Cookies” &bc.cookies.ToString())
July 29, 2008 92
ASP.NET Objects
Response Objects:
Designing: Webform1
Coding:
Webform1 Coding:
Sub button1_Click()
Response.cookies(“Cricket”) (Textbox1.Text)= Request.Form(label1.Text)
Response.cookies(“Cricket”) (Textbox2.Text)= Request.Form(label2.Text)
Response.cookies(“Cricket”) (Textbox3.Text)= Request.Form(label3.Text)
Response. Redirect(“webform2.aspx”)
Webform2 Coding:
Page_load()
If (Request.cookies (“Cricket”).Haskeys) then
Response.Write(Request.cookies (“Cricket”)value)
End If
Global Object:
Coding:
Webform:
Sub Page_load()
Response.Write (“Count”, &Application.Get(“Count”))
1. Page Directives
Page Directives are used when we want to write C# code in ASP.NET<%@pageload= C #>
2. Import Directives
When ever we are writing VB.NET code behind we have to import the library file with the help
of Import
directive from .NET Common Library Management.
4. Register Directives
If We want the same design and same code again and again in ASP.NET we are using Register
Directives.
5. #Include Directives
If the code behind is written in C# then we have to import the library files with the help of this
directives.
July 29, 2008 97
Web Services
Web services are used for security purpose and if there is a
possibility of using the same code is there.
Rapid development
More Secure.
Next it will display the following window. Here Click the add
button.
Now the following window will display. Enter the value of a and
b.
Now press the Invoke Button to get the output. It will display
the
following Result.
Window Application
Web Application
Console Application
Simple
Consistent
Modern
Object Oriented
Type Safety
Versionable
Compatible
Flexible
July 29, 2008 104
C# Statements
If Statement
Executes statement based on the value of a Boolean expression.
Switch Statement
Based on the value of a variable allows to switch to different cases.
Do Loop
The purpose of the do loop is to Execute some code and then examine the
condition.
If the condition is not satisfied then the execution is stopped.
While Loop
Evaluate the condition first and then execute the code if the condition is
true.
For Loop
Executes the statement based on the condition within the for statement.
Foreach Statement
Moves through the elements of a collection of elements.
Class
Class is the central element in Object Oriented Language.
Class is the collection of Objects and Methods.
Class is the blueprint of Objects.
A Class is declared using the class keyword.
Object
In object-oriented programming, an object is an instance of
a class
Object is a kind of module containing data and subroutines.
An object is a kind of self-sufficient entity that has an
internal state (the data it contains) and that can respond to
messages (calls to its
subroutines).
July 29, 2008 107
Basic Knowledge needed to learn C#
Function
A function is a block of code that performs a calculation and
returns a value.
Syntax:
returntype fn_name(parameterdef1, parameterdef2, )
{
local variables
function code
July 29, 2008 108
}
Constructor in C#
A constructor can be used, where every time an object gets
create and if we want some code to be executed automatically.
The code that we want to execute must be put in the
constructor.
Example:
class Complex
{
public Complex()
{
// constructor
}
~Complex()
{
// Destructor
}
}
1. Encapsulation
2. Inheritance
3. Polymorphism
4. Abstraction
1. Single Inheritance:
2. Multi-level Inheritance:
3. Multiple Inheritance:
4. Hybrid Inheritance:
The hybrid inheritance can also be done through with the help
of interface. Here the derived class cans implements more than
two interfaces and only one class.
using System;
class Base
{
public void fun() class Main
{ {
Console.WriteLine(“Base Class”); public static void Main()
} {
} derived obj=new derived();
class derived : Base obj.run();
{ }
public void run() }
{
Console.WriteLine(“Derived Class”);
fun();
}
}
using System;
Interface i1 Public void put();
{ {
public void Accept(); Console.WriteLine(“Microsoft”);
}
} }
Interface i2 class Main
{ {
public void put() ; public static void Main()
}
{
Public class A : i1,i2
{ i1 obj=new A();
public void Accept() i2 obj1=new A();
{ obj.Accept();
Console.WriteLine(“ C# dot net”); obj1.put();
}
}
}
July 29, 2008 125
Polymorphism in C#
Polymorphism
Function
Type Cast Abstract Class
Signatur
e
Number of Type
July 29, 2008 126
Polymorphism in C#
Function Overloading :
C# allows us to define multiple functions with the same
name differing in the number type and order of arguments.
This is termed as function overloading.
using System;
class Overloading
{
public void fun(int a)
{
int num=a;
Console.WriteLine(num);
}
public void fun(int a,float b)
{
int num1=a;
float num2=b;
Console.WriteLine("{0}{1}",num1,num2);
}
public static void Main()
{
Overloading obj=new Overloading();
obj.fun(10);
obj1.fun(100,200f);
Console.ReadLine();
}
}
July 29, 2008 128
Polymorphism in C#
Operator Overloading:
Operator function can take only value arguments. The ref and
out parameters are not allowed as arguments to operator
functions.
Operators Overloadability
All C# binary operators can be
+, -, *, /, %, &, |, <<, >>
overloaded.
All C# unary operators can be
+, -, !, ~, ++, --, true, false
overloaded.
All relational operators can be
==, !=, <, >, <= , >=
overloaded, but only as pairs.
&&, ||, () They can't be overloaded
In C#, these operators are
+=, -=, *=, /=, %= automatically overloaded when the
respective binary operator is
=, . , ?:, ->, new, is, as, overloaded.
These operators can't be overloaded
sizeof
using System;
class BC
{ class Demo
public virtual void Display() {
{ public static void Main()
System.Console.WriteLine("BC::Display"); {
} BC b;
} b = new DC();
class DC : BC b.Display(); //DC ::
{ Display
public override void Display() }
{ }
System.Console.WriteLine("DC::Display");
}
}
For eg: The car salesman giving only the relevant information to
the customer.