SlideShare una empresa de Scribd logo
1 de 23
Collection
A collection is a group of objects
Collection
• A collection is a group of objects. The
.NET Framework contains a large number
of interfaces and classes that define and
implement various types of collections.
• Originally, there were only non-generic
collection classes.
Collection
• The principal benefit of collections is that they
standardize the way groups of objects are
handled by your programs.
• All collections are designed around a set of
cleanly defined interfaces. Several built-in
implementations of these interfaces, such as
ArrayList, Hashtable, Stack, and Queue, are
provided, which you can use as-is.
• The .NET Framework supports five general
types of collections: non-generic, specialized,
bit-based, generic, and concurrent.
non-generic
• The non-generic collections have been part of the .NET
Framework since version 1.0.
• They are defined in the System.Collections
namespace.
• The non-generic collections are general-purpose data
structures that operate on object references.
• Thus, they can manage any type of object, but not in a
type-safe manner.
• you can mix various types of data within the same
collection.
• non-generic collections do not have the type-safety that
is found in the generic collections.
• The non-generic collections implement several
fundamental data structures, including a dynamic array,
stack, and queue.
• They also include dictionaries, in which you can store
key/value pairs.
Specialized Collections
• The specialized collections operate on a specific type of
data or operate in a unique way.
• For example, there are specialized collections for
strings.
• The specialized collections are declared in
System.Collections.Specialized.
• Specialized Collection:-HybridDictionary, ListDictionary,
NameValueCollection, StringDictionary etc.
• System.Collections also defines three abstract base
classes, CollectionBase, ReadOnlyCollectionBase, and
DictionaryBase, which can be inherited and used.
Bit-based
• The Collections API defines one bit-based
collection called BitArray class.
• BitArray supports bitwise operations on bits,
such as AND and XOR.
• BitArray is declared in System.Collections.
• it still supports the basic collection underpinning
by implementing ICollection and IEnumerable.
• You can construct a BitArray from an array of
Boolean values using this constructor:
• public BitArray(bool[ ] values)
Generic Collection
•
•
•
•
•
•

The generic collections provide generic implementations of several
standard data structures, such as linked lists, stacks, queues, and
dictionaries.
Because these collections are generic, they are type-safe.
This means that only items that are type-compatible with the type of
the collection can be stored in a generic collection, thus eliminating
accidental type mismatches.
Generic collections are declared in System.Collections.Generic
namespace.
There is a generic collection called LinkedList that implements a
doubly linked list, but no non-generic equivalent.

The generic collections work in the same way as the non-generic
collections with the exception that a generic collection is type-safe.
• For all cases in which a collection is storing only one type of
object, then a generic collection is your best choice
Concurrent Collection
• The .NET Framework version 4.0 adds a new
namespace called
System.Collections.Concurrent.
• It contains collections that are thread-safe and
designed to be used for parallel programming.
• The concurrent collections support
multithreaded access to a collection.
• Concurrent Collection:-BlockingCollection<T>,
ConcurrentDictionary<TKey, TValue> etc.
Next…..
Handling Network Errors
• To handle network exceptions that the program
might generate, you must monitor calls to
Create( ), GetResponse( ), and
GetResponseStream( ).
• It is important to understand that the exceptions
that can be generated depend upon the protocol
being used.
• The following discussion describes several of
the exceptions possible when using HTTP.
Exceptions Generated by Create( )
• The Create( ) method defined by WebRequest it can
generate four exceptions.
• If the protocol specified by the URI prefix is not
supported, then NotSupportedException is thrown.
• If the URI format is invalid, UriFormatException is
thrown.
• If the user does not have the proper authorization, a
System.Security.SecurityException will be thrown.
• Create( ) can also throw an ArgumentNullException if
it is called with a null reference, but this is not an error
generated by networking.

• WebRequest.Create("http://www.McGrawHill.com")
Exceptions Generated by
GetReponse( )
•

A number of errors can occur when obtaining an HTTP response by
calling GetResponse( ).

•

These are represented by the following exceptions:
InvalidOperationException, ProtocolViolationException,
NotSupportedException, and WebException. Of these, the one of
most interest is WebException.

•

WebException has two properties that relate to network errors:
Response and Status.
• You can obtain a reference to the WebResponse object inside an
exception handler through the Response property.
• When an error occurs, you can use the Status property of
WebException to find out what went wrong.
Exceptions Generated by
GetResponseStream( )
• For the HTTP protocol, the GetResponseStream( )
method of WebResponse can throw a
ProtocolViolationException, which, in general, means
that some error occurred relative to the specified
protocol.
• As it relates to GetResponseStream( ), it means that no
valid response stream is available.
• An ObjectDisposedException will be thrown if the
response has already been disposed.
• Of course, an IOException could occur while reading
the stream, depending on how input is accomplished
• The program begins by creating a WebRequest object
that contains the desired URI. Notice that the Create( )
method, rather than a constructor, is used for this
purpose. Create( ) is a static member of WebRequest.
Even though WebRequest is an abstract class, it is still
possible to call a static method of that class. Create( )
returns a WebRequest object that has the proper
protocol “plugged in,” based on the protocol prefix of the
URI. In this case, the protocol is HTTP. Thus, Create( )
returns an HttpWebRequest object. Of course, its return
value must still be cast to HttpWebRequest when it is
assigned to the HttpWebRequest reference called req.
At this point, the request has been created, but not yet
sent to the specified URI.
• To send the request, the program calls
GetResponse( ) on the WebRequest object.
After the request has been sent, GetResponse( )
waits for a response. Once a response has been
received, GetResponse( ) returns a
WebResponse object that encapsulates the
response. This object is assigned to resp. Since,
in this case, the response uses the HTTP
protocol, the result is cast to HttpWebResponse.
Among other things, the response contains a
stream that can be used to read data from the
URI.
• Next, an input stream is obtained by
calling GetResponseStream( ) on resp.
This is a standard Stream object, having
all of the attributes and features of any
other input stream. A reference to the
stream is assigned to istrm. Using istrm,
the data at the specified URI can be read
in the same way that a file is read.
Next….
COM
• COM has been Microsoft’s model for
programming components in a variety of
languages, which can be built into distributed
applications.
• The .NET Framework includes support for COM
clients to use .NET components. When a COM
client needs to create a .NET object, the CLR
creates the managed object and a COM callable
wrapper (CCW) that wraps the object. The COM
client interacts with the managed object through
the CCW.
Types that need to be accessed by COM
clients must meet certain requirements :
• The managed type (class, interface, struct, or
enum) must be public.
• If the COM client needs to create the object, it
must have a public default constructor. COM
does not support parameterized constructors.
• The members of the type that are being
accessed must be public instance members.
• Private, protected, internal, and static
members are not accessible to COM clients.
Marshalling and Unmarshalling
• Marshalling governs how data is passed in
method arguments and return values between
managed and unmanaged memory during calls.
Interoperation marshalling is a run-time activity
performed by the common language runtime's
marshaling service. In few words, "Marshalling"
refers to the process of converting the data or
the objects into a byte-stream, and
"Unmarshalling" is the reverse process of
converting the byte-stream back to their original
data or object.
Usefulness of marshalling
• The .NET framework is a natural progression
from COM because the two models (assembly
or com) share many central themes, including
component reuse and language neutrality. For
backward compatibility, COM interop provides
access to existing COM components without
requiring that the original component be
modified. You can incorporate COM components
into a .NET Framework application by using
COM interop tools to import the relevant COM
types. Once imported, the COM types are ready
to use.
COM
• COM interoperability also introduces forward
compatibility by enabling your COM clients to
access managed code as easily as they access
other COM objects. Again, COM interoperability
provides the means to seamlessly export
metadata in an assembly to a type library and
registers the managed component as a
traditional COM component. Both the import and
export utilities produce results consistent with
COM specifications.
• Dynamic Method Dispatch.
• Synchronous Calling.
• Method Group Conversion.

Más contenido relacionado

La actualidad más candente

Learnadvancedjavaprogramming 131217055604-phpapp02
Learnadvancedjavaprogramming 131217055604-phpapp02Learnadvancedjavaprogramming 131217055604-phpapp02
Learnadvancedjavaprogramming 131217055604-phpapp02Hardeep Kaur
 
C++ training
C++ training C++ training
C++ training PL Sharma
 
Servlets as introduction (Advanced programming)
Servlets as introduction (Advanced programming)Servlets as introduction (Advanced programming)
Servlets as introduction (Advanced programming)Gera Paulos
 
Advanced programming ch2
Advanced programming ch2Advanced programming ch2
Advanced programming ch2Gera Paulos
 
Serialization in .NET
Serialization in .NETSerialization in .NET
Serialization in .NETAbhi Arya
 
Serialization/deserialization
Serialization/deserializationSerialization/deserialization
Serialization/deserializationYoung Alista
 
Certification preparation - Net classses and functions.pptx
Certification preparation - Net classses and functions.pptxCertification preparation - Net classses and functions.pptx
Certification preparation - Net classses and functions.pptxRohit Radhakrishnan
 
.Net Classes and Objects | UiPath Community
.Net Classes and Objects | UiPath Community.Net Classes and Objects | UiPath Community
.Net Classes and Objects | UiPath CommunityRohit Radhakrishnan
 
Certification preparation - Error Handling and Troubleshooting recap.pptx
Certification preparation - Error Handling and Troubleshooting recap.pptxCertification preparation - Error Handling and Troubleshooting recap.pptx
Certification preparation - Error Handling and Troubleshooting recap.pptxRohit Radhakrishnan
 
Data Persistence in Android with Room Library
Data Persistence in Android with Room LibraryData Persistence in Android with Room Library
Data Persistence in Android with Room LibraryReinvently
 
Java IO Package and Streams
Java IO Package and StreamsJava IO Package and Streams
Java IO Package and Streamsbabak danyal
 
Understanding C# in .NET
Understanding C# in .NETUnderstanding C# in .NET
Understanding C# in .NETmentorrbuddy
 
Reflection in C Sharp
Reflection in C SharpReflection in C Sharp
Reflection in C SharpHarman Bajwa
 

La actualidad más candente (17)

Learnadvancedjavaprogramming 131217055604-phpapp02
Learnadvancedjavaprogramming 131217055604-phpapp02Learnadvancedjavaprogramming 131217055604-phpapp02
Learnadvancedjavaprogramming 131217055604-phpapp02
 
C++ training
C++ training C++ training
C++ training
 
Servlets as introduction (Advanced programming)
Servlets as introduction (Advanced programming)Servlets as introduction (Advanced programming)
Servlets as introduction (Advanced programming)
 
Advanced programming ch2
Advanced programming ch2Advanced programming ch2
Advanced programming ch2
 
Java util
Java utilJava util
Java util
 
Serialization in .NET
Serialization in .NETSerialization in .NET
Serialization in .NET
 
Serialization/deserialization
Serialization/deserializationSerialization/deserialization
Serialization/deserialization
 
Advanced c#
Advanced c#Advanced c#
Advanced c#
 
Certification preparation - Net classses and functions.pptx
Certification preparation - Net classses and functions.pptxCertification preparation - Net classses and functions.pptx
Certification preparation - Net classses and functions.pptx
 
.Net Classes and Objects | UiPath Community
.Net Classes and Objects | UiPath Community.Net Classes and Objects | UiPath Community
.Net Classes and Objects | UiPath Community
 
Collections
CollectionsCollections
Collections
 
Certification preparation - Error Handling and Troubleshooting recap.pptx
Certification preparation - Error Handling and Troubleshooting recap.pptxCertification preparation - Error Handling and Troubleshooting recap.pptx
Certification preparation - Error Handling and Troubleshooting recap.pptx
 
Data Persistence in Android with Room Library
Data Persistence in Android with Room LibraryData Persistence in Android with Room Library
Data Persistence in Android with Room Library
 
Les23
Les23Les23
Les23
 
Java IO Package and Streams
Java IO Package and StreamsJava IO Package and Streams
Java IO Package and Streams
 
Understanding C# in .NET
Understanding C# in .NETUnderstanding C# in .NET
Understanding C# in .NET
 
Reflection in C Sharp
Reflection in C SharpReflection in C Sharp
Reflection in C Sharp
 

Destacado

Powerpoint de inskape
Powerpoint de inskapePowerpoint de inskape
Powerpoint de inskape131Plutarco
 
Curso de inkscape
Curso de inkscapeCurso de inkscape
Curso de inkscapeLourdes Pla
 
Inkscape Dibuja Libremente
Inkscape Dibuja LibrementeInkscape Dibuja Libremente
Inkscape Dibuja LibrementeSyra Lacruz
 
Dibujando Con Inkscape
Dibujando Con InkscapeDibujando Con Inkscape
Dibujando Con InkscapeSyra Lacruz
 
Diseñar gráficos sencillos con inkscape
Diseñar gráficos sencillos con inkscapeDiseñar gráficos sencillos con inkscape
Diseñar gráficos sencillos con inkscapeKoldo Parra
 

Destacado (8)

Powerpoint de inskape
Powerpoint de inskapePowerpoint de inskape
Powerpoint de inskape
 
Tutorial Inscape
Tutorial InscapeTutorial Inscape
Tutorial Inscape
 
Vectorizar en inkscape
Vectorizar en inkscapeVectorizar en inkscape
Vectorizar en inkscape
 
circulacion mayor y menor
circulacion mayor y menorcirculacion mayor y menor
circulacion mayor y menor
 
Curso de inkscape
Curso de inkscapeCurso de inkscape
Curso de inkscape
 
Inkscape Dibuja Libremente
Inkscape Dibuja LibrementeInkscape Dibuja Libremente
Inkscape Dibuja Libremente
 
Dibujando Con Inkscape
Dibujando Con InkscapeDibujando Con Inkscape
Dibujando Con Inkscape
 
Diseñar gráficos sencillos con inkscape
Diseñar gráficos sencillos con inkscapeDiseñar gráficos sencillos con inkscape
Diseñar gráficos sencillos con inkscape
 

Similar a Collection

Introducing object oriented programming (oop)
Introducing object oriented programming (oop)Introducing object oriented programming (oop)
Introducing object oriented programming (oop)Hemlathadhevi Annadhurai
 
DSpace 4.2 Transmission: Import/Export
DSpace 4.2 Transmission: Import/ExportDSpace 4.2 Transmission: Import/Export
DSpace 4.2 Transmission: Import/ExportDuraSpace
 
.net Based Component Technologies
.net Based Component Technologies.net Based Component Technologies
.net Based Component Technologiesprakashk453625
 
The Meteor Framework
The Meteor FrameworkThe Meteor Framework
The Meteor FrameworkDamien Magoni
 
J2EE : Java servlet and its types, environment
J2EE : Java servlet and its types, environmentJ2EE : Java servlet and its types, environment
J2EE : Java servlet and its types, environmentjoearunraja2
 
Software design with Domain-driven design
Software design with Domain-driven design Software design with Domain-driven design
Software design with Domain-driven design Allan Mangune
 
BlueHat v17 || Dangerous Contents - Securing .Net Deserialization
BlueHat v17 || Dangerous Contents - Securing .Net Deserialization BlueHat v17 || Dangerous Contents - Securing .Net Deserialization
BlueHat v17 || Dangerous Contents - Securing .Net Deserialization BlueHat Security Conference
 
Introduction to Design Patterns in Javascript
Introduction to Design Patterns in JavascriptIntroduction to Design Patterns in Javascript
Introduction to Design Patterns in JavascriptSanthosh Kumar Srinivasan
 
Collection framework
Collection frameworkCollection framework
Collection frameworkJainul Musani
 
Introduction to Spring
Introduction to SpringIntroduction to Spring
Introduction to SpringSujit Kumar
 
C# Advanced L07-Design Patterns
C# Advanced L07-Design PatternsC# Advanced L07-Design Patterns
C# Advanced L07-Design PatternsMohammad Shaker
 
1. Java Collections Framework Introduction
1. Java Collections Framework Introduction1. Java Collections Framework Introduction
1. Java Collections Framework IntroductionBharat Savani
 

Similar a Collection (20)

Collections
CollectionsCollections
Collections
 
Introducing object oriented programming (oop)
Introducing object oriented programming (oop)Introducing object oriented programming (oop)
Introducing object oriented programming (oop)
 
DSpace 4.2 Transmission: Import/Export
DSpace 4.2 Transmission: Import/ExportDSpace 4.2 Transmission: Import/Export
DSpace 4.2 Transmission: Import/Export
 
.net Based Component Technologies
.net Based Component Technologies.net Based Component Technologies
.net Based Component Technologies
 
The Meteor Framework
The Meteor FrameworkThe Meteor Framework
The Meteor Framework
 
Hibernate tutorial
Hibernate tutorialHibernate tutorial
Hibernate tutorial
 
J2EE : Java servlet and its types, environment
J2EE : Java servlet and its types, environmentJ2EE : Java servlet and its types, environment
J2EE : Java servlet and its types, environment
 
Software design with Domain-driven design
Software design with Domain-driven design Software design with Domain-driven design
Software design with Domain-driven design
 
BlueHat v17 || Dangerous Contents - Securing .Net Deserialization
BlueHat v17 || Dangerous Contents - Securing .Net Deserialization BlueHat v17 || Dangerous Contents - Securing .Net Deserialization
BlueHat v17 || Dangerous Contents - Securing .Net Deserialization
 
Introduction to Design Patterns in Javascript
Introduction to Design Patterns in JavascriptIntroduction to Design Patterns in Javascript
Introduction to Design Patterns in Javascript
 
Collection framework
Collection frameworkCollection framework
Collection framework
 
Introduction to Spring
Introduction to SpringIntroduction to Spring
Introduction to Spring
 
Design_Patterns_Dr.CM.ppt
Design_Patterns_Dr.CM.pptDesign_Patterns_Dr.CM.ppt
Design_Patterns_Dr.CM.ppt
 
06.1 .Net memory management
06.1 .Net memory management06.1 .Net memory management
06.1 .Net memory management
 
Real-Time Design Patterns
Real-Time Design PatternsReal-Time Design Patterns
Real-Time Design Patterns
 
C# Advanced L07-Design Patterns
C# Advanced L07-Design PatternsC# Advanced L07-Design Patterns
C# Advanced L07-Design Patterns
 
1. Java Collections Framework Introduction
1. Java Collections Framework Introduction1. Java Collections Framework Introduction
1. Java Collections Framework Introduction
 
Apex code (Salesforce)
Apex code (Salesforce)Apex code (Salesforce)
Apex code (Salesforce)
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
 

Más de abhay singh (15)

Iso 27001
Iso 27001Iso 27001
Iso 27001
 
Web service
Web serviceWeb service
Web service
 
Unsafe
UnsafeUnsafe
Unsafe
 
Threading
ThreadingThreading
Threading
 
Preprocessor
PreprocessorPreprocessor
Preprocessor
 
Networking and socket
Networking and socketNetworking and socket
Networking and socket
 
Namespace
NamespaceNamespace
Namespace
 
Inheritance
InheritanceInheritance
Inheritance
 
Generic
GenericGeneric
Generic
 
Gdi
GdiGdi
Gdi
 
Exception
ExceptionException
Exception
 
Delegate
DelegateDelegate
Delegate
 
Constructor
ConstructorConstructor
Constructor
 
Ado
AdoAdo
Ado
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 

Último

9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 

Último (20)

9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 

Collection

  • 1. Collection A collection is a group of objects
  • 2. Collection • A collection is a group of objects. The .NET Framework contains a large number of interfaces and classes that define and implement various types of collections. • Originally, there were only non-generic collection classes.
  • 3. Collection • The principal benefit of collections is that they standardize the way groups of objects are handled by your programs. • All collections are designed around a set of cleanly defined interfaces. Several built-in implementations of these interfaces, such as ArrayList, Hashtable, Stack, and Queue, are provided, which you can use as-is. • The .NET Framework supports five general types of collections: non-generic, specialized, bit-based, generic, and concurrent.
  • 4. non-generic • The non-generic collections have been part of the .NET Framework since version 1.0. • They are defined in the System.Collections namespace. • The non-generic collections are general-purpose data structures that operate on object references. • Thus, they can manage any type of object, but not in a type-safe manner. • you can mix various types of data within the same collection. • non-generic collections do not have the type-safety that is found in the generic collections. • The non-generic collections implement several fundamental data structures, including a dynamic array, stack, and queue. • They also include dictionaries, in which you can store key/value pairs.
  • 5. Specialized Collections • The specialized collections operate on a specific type of data or operate in a unique way. • For example, there are specialized collections for strings. • The specialized collections are declared in System.Collections.Specialized. • Specialized Collection:-HybridDictionary, ListDictionary, NameValueCollection, StringDictionary etc. • System.Collections also defines three abstract base classes, CollectionBase, ReadOnlyCollectionBase, and DictionaryBase, which can be inherited and used.
  • 6. Bit-based • The Collections API defines one bit-based collection called BitArray class. • BitArray supports bitwise operations on bits, such as AND and XOR. • BitArray is declared in System.Collections. • it still supports the basic collection underpinning by implementing ICollection and IEnumerable. • You can construct a BitArray from an array of Boolean values using this constructor: • public BitArray(bool[ ] values)
  • 7. Generic Collection • • • • • • The generic collections provide generic implementations of several standard data structures, such as linked lists, stacks, queues, and dictionaries. Because these collections are generic, they are type-safe. This means that only items that are type-compatible with the type of the collection can be stored in a generic collection, thus eliminating accidental type mismatches. Generic collections are declared in System.Collections.Generic namespace. There is a generic collection called LinkedList that implements a doubly linked list, but no non-generic equivalent. The generic collections work in the same way as the non-generic collections with the exception that a generic collection is type-safe. • For all cases in which a collection is storing only one type of object, then a generic collection is your best choice
  • 8. Concurrent Collection • The .NET Framework version 4.0 adds a new namespace called System.Collections.Concurrent. • It contains collections that are thread-safe and designed to be used for parallel programming. • The concurrent collections support multithreaded access to a collection. • Concurrent Collection:-BlockingCollection<T>, ConcurrentDictionary<TKey, TValue> etc.
  • 10. Handling Network Errors • To handle network exceptions that the program might generate, you must monitor calls to Create( ), GetResponse( ), and GetResponseStream( ). • It is important to understand that the exceptions that can be generated depend upon the protocol being used. • The following discussion describes several of the exceptions possible when using HTTP.
  • 11. Exceptions Generated by Create( ) • The Create( ) method defined by WebRequest it can generate four exceptions. • If the protocol specified by the URI prefix is not supported, then NotSupportedException is thrown. • If the URI format is invalid, UriFormatException is thrown. • If the user does not have the proper authorization, a System.Security.SecurityException will be thrown. • Create( ) can also throw an ArgumentNullException if it is called with a null reference, but this is not an error generated by networking. • WebRequest.Create("http://www.McGrawHill.com")
  • 12. Exceptions Generated by GetReponse( ) • A number of errors can occur when obtaining an HTTP response by calling GetResponse( ). • These are represented by the following exceptions: InvalidOperationException, ProtocolViolationException, NotSupportedException, and WebException. Of these, the one of most interest is WebException. • WebException has two properties that relate to network errors: Response and Status. • You can obtain a reference to the WebResponse object inside an exception handler through the Response property. • When an error occurs, you can use the Status property of WebException to find out what went wrong.
  • 13. Exceptions Generated by GetResponseStream( ) • For the HTTP protocol, the GetResponseStream( ) method of WebResponse can throw a ProtocolViolationException, which, in general, means that some error occurred relative to the specified protocol. • As it relates to GetResponseStream( ), it means that no valid response stream is available. • An ObjectDisposedException will be thrown if the response has already been disposed. • Of course, an IOException could occur while reading the stream, depending on how input is accomplished
  • 14. • The program begins by creating a WebRequest object that contains the desired URI. Notice that the Create( ) method, rather than a constructor, is used for this purpose. Create( ) is a static member of WebRequest. Even though WebRequest is an abstract class, it is still possible to call a static method of that class. Create( ) returns a WebRequest object that has the proper protocol “plugged in,” based on the protocol prefix of the URI. In this case, the protocol is HTTP. Thus, Create( ) returns an HttpWebRequest object. Of course, its return value must still be cast to HttpWebRequest when it is assigned to the HttpWebRequest reference called req. At this point, the request has been created, but not yet sent to the specified URI.
  • 15. • To send the request, the program calls GetResponse( ) on the WebRequest object. After the request has been sent, GetResponse( ) waits for a response. Once a response has been received, GetResponse( ) returns a WebResponse object that encapsulates the response. This object is assigned to resp. Since, in this case, the response uses the HTTP protocol, the result is cast to HttpWebResponse. Among other things, the response contains a stream that can be used to read data from the URI.
  • 16. • Next, an input stream is obtained by calling GetResponseStream( ) on resp. This is a standard Stream object, having all of the attributes and features of any other input stream. A reference to the stream is assigned to istrm. Using istrm, the data at the specified URI can be read in the same way that a file is read.
  • 18. COM • COM has been Microsoft’s model for programming components in a variety of languages, which can be built into distributed applications. • The .NET Framework includes support for COM clients to use .NET components. When a COM client needs to create a .NET object, the CLR creates the managed object and a COM callable wrapper (CCW) that wraps the object. The COM client interacts with the managed object through the CCW.
  • 19. Types that need to be accessed by COM clients must meet certain requirements : • The managed type (class, interface, struct, or enum) must be public. • If the COM client needs to create the object, it must have a public default constructor. COM does not support parameterized constructors. • The members of the type that are being accessed must be public instance members. • Private, protected, internal, and static members are not accessible to COM clients.
  • 20. Marshalling and Unmarshalling • Marshalling governs how data is passed in method arguments and return values between managed and unmanaged memory during calls. Interoperation marshalling is a run-time activity performed by the common language runtime's marshaling service. In few words, "Marshalling" refers to the process of converting the data or the objects into a byte-stream, and "Unmarshalling" is the reverse process of converting the byte-stream back to their original data or object.
  • 21. Usefulness of marshalling • The .NET framework is a natural progression from COM because the two models (assembly or com) share many central themes, including component reuse and language neutrality. For backward compatibility, COM interop provides access to existing COM components without requiring that the original component be modified. You can incorporate COM components into a .NET Framework application by using COM interop tools to import the relevant COM types. Once imported, the COM types are ready to use.
  • 22. COM • COM interoperability also introduces forward compatibility by enabling your COM clients to access managed code as easily as they access other COM objects. Again, COM interoperability provides the means to seamlessly export metadata in an assembly to a type library and registers the managed component as a traditional COM component. Both the import and export utilities produce results consistent with COM specifications.
  • 23. • Dynamic Method Dispatch. • Synchronous Calling. • Method Group Conversion.