Introduction To .Net
-
Upload
soumya-ramachandran -
Category
Documents
-
view
306 -
download
2
Transcript of Introduction To .Net
IMPLEMENTING SYSTEM TYPES IMPLEMENTING SYSTEM TYPES
AND AND
INTERFACESINTERFACES
11
Primary System TypesPrimary System TypesSystem TypesSystem Types
Simple Types and complex typesSimple Types and complex types
EnvironmentsEnvironments
Loosely Typed environmentLoosely Typed environment
You can store multiple types of dataYou can store multiple types of data
Cannot ensure type safetyCannot ensure type safety
Strongly Typed environmentStrongly Typed environment
Variable is explicitly assignedVariable is explicitly assigned
Ensure type safetyEnsure type safety
22
3
.Net Framework 2.03
Common Type SystemCommon Type System
Common set of data typeCommon set of data type
Base type System. ObjectBase type System. Object
Value typesValue types
Contains actual data assigned to them Contains actual data assigned to them
Built in : simple Primitive data typesBuilt in : simple Primitive data types
User DefinedUser Defined
Structure: Store logically related valuesStructure: Store logically related values
Constant: Store values that need not changedConstant: Store values that need not changed
Enumeration: List of named integer constantsEnumeration: List of named integer constants
4
.Net Framework 2.04
System Types Contd…System Types Contd…Reference TypesReference Types
Contains references to assigned data.Contains references to assigned data.
Two types of reference data typeTwo types of reference data type
ClassesClasses
Like templates Like templates
InterfacesInterfaces
Defines standard behavior for classesDefines standard behavior for classes
Boxing: Conversion of value type to referenceBoxing: Conversion of value type to reference
Boxing: Explicit conversion of reference to Boxing: Explicit conversion of reference to value typevalue type
5
.Net Framework 2.05
6
.Net Framework 2.06
Data type conversion in .net framework.Data type conversion in .net framework. Performed either explicitly or implicitly.Performed either explicitly or implicitly. Implicit: Narrow data to wide data.Implicit: Narrow data to wide data. Explicit: Wide data to narrow data.Explicit: Wide data to narrow data. Generics: Define custom types that are type safeGenerics: Define custom types that are type safe Advantages: Reusability ,Type safety, Advantages: Reusability ,Type safety,
performance..performance.. Nullable types: You can assign null values .Nullable types: You can assign null values . Exceptions: Error conditions.Exceptions: Error conditions. Predefined and User defined Exceptions.Predefined and User defined Exceptions. Attributes: To convey information to the run time .Attributes: To convey information to the run time . Predefined and custom Attributes.Predefined and custom Attributes.
CastingCasting
7
.Net Framework 2.07
InterfacesInterfacesInterfaces are nothing more than definitions of Interfaces are nothing more than definitions of contracts.contracts.
Single and multiple interfacesSingle and multiple interfaces
IComparable: Generalized comparison method.IComparable: Generalized comparison method.
IEquitable:Only to generics. Used to check equality.IEquitable:Only to generics. Used to check equality.
IConvertable: To convert an object to CLR typeIConvertable: To convert an object to CLR type
IClonable:To create an object and new reference IClonable:To create an object and new reference variablevariable
Shallow Cloning: Copying an object without referencesShallow Cloning: Copying an object without references
Deep Cloning: Copying object with references to other Deep Cloning: Copying object with references to other objectsobjects
8
.Net Framework 2.08
Interfaces contd...Interfaces contd...
IFormattable:To format the value of the current instance IFormattable:To format the value of the current instance by specified format.by specified format.
IDisposable:To release unmanaged resources explicitly.IDisposable:To release unmanaged resources explicitly.
9
.Net Framework 2.09
IMPLEMENTING COLLECTIONS IMPLEMENTING COLLECTIONS AND AND
GENERICSGENERICS
10
.Net Framework 2.010
CollectionsCollections
You an store several items within one object.You an store several items within one object.
Arrays:System.Array.To store any type of data.Arrays:System.Array.To store any type of data.
Non Generic :You could store multiple objectsNon Generic :You could store multiple objects
No guarantee in type safetyNo guarantee in type safety
Generic : You can specify the data type you want to Generic : You can specify the data type you want to store.store.
Making development less error – prone.Making development less error – prone.
Collection Interface: Each interface allows collection Collection Interface: Each interface allows collection
class to support a different behaviorclass to support a different behavior . .
11
.Net Framework 2.011
Primary Collection TypesPrimary Collection TypesFor storing multiple unrelated types.For storing multiple unrelated types.
ArrayList: Similar to single dimension array.ArrayList: Similar to single dimension array.
Stack: Retrieve objects in the reverse order which you Stack: Retrieve objects in the reverse order which you added them (LIFO).added them (LIFO).
Queue: Retrieve objects in the same order which you Queue: Retrieve objects in the same order which you added them (FIFO)added them (FIFO)
IEnumerable Interface: To iterate through member of IEnumerable Interface: To iterate through member of collection.collection.
Comparer Class: Compares two objects to detect if Comparer Class: Compares two objects to detect if they are less than greater than to one another. they are less than greater than to one another.
12
.Net Framework 2.012
Hash table class: To represent name /value pairs based Hash table class: To represent name /value pairs based on hash code.on hash code.
Sorted List Class: To represent name /value pairs Sorted List Class: To represent name /value pairs accessible either by key or by index.accessible either by key or by index.
BitArray Class: You can implement bit structures.BitArray Class: You can implement bit structures.
Generic List Class: Provides methods to sort search Generic List Class: Provides methods to sort search and manipulate elements of generic list.and manipulate elements of generic list.
Generic Stack Class: Represents a variable size LIFO Generic Stack Class: Represents a variable size LIFO Collection of objects of same data. Collection of objects of same data.
Generic Queue Class: Represents a variable size FIFO Generic Queue Class: Represents a variable size FIFO Collection of objects of same data. Collection of objects of same data.
13
.Net Framework 2.013
Generic Linked List class: Nodes that have a common Generic Linked List class: Nodes that have a common data type.data type.
Specialized Collections: To serve a special or highly Specialized Collections: To serve a special or highly specific purpose.specific purpose.
Collection base class: Represents an abstract class for Collection base class: Represents an abstract class for a strongly typed collection.a strongly typed collection.
Read-only Collection Base Class: Represents an Read-only Collection Base Class: Represents an abstract base class for a strongly typed non generic abstract base class for a strongly typed non generic collection.collection.
Dictionary Base Class: Represents an abstract base Dictionary Base Class: Represents an abstract base class for a strongly types collection of key value pairs.class for a strongly types collection of key value pairs.
Dictionary Entry Type: Defines a dictionary key value Dictionary Entry Type: Defines a dictionary key value pair.pair.