Book description
Build the skills to apply Microsoft .NET collections effectively
Put .NET collections to work—and manage issues with GUI data binding, threading, data querying, and storage. Led by a data collection expert, you'll gain task-oriented guidance, exercises, and extensive code samples to tackle common problems and improve application performance. This one-stop reference is designed for experienced Microsoft Visual Basic and C# developers—whether you’re already using collections or just starting out.
Discover how to:
Implement arrays, associative arrays, stacks, linked lists, and other collection types
Apply built in .NET collection classes by learning their methods and properties
Add enumerator, dictionary, and other .NET collection interfaces to your classes
Query collections by writing simple to complex Microsoft LINQ statements
Synchronize data across threads using built in .NET synchronization classes
Enhance your custom collection classes with serialization support
Use simple data binding to display collections in Windows Forms, Microsoft Silverlight, and Windows Presentation Foundation
Table of contents
- Introduction
-
I. Collection Basics
- 1. Understanding Collections: Arrays and Linked Lists
-
2. Understanding Collections: Associative Arrays
- Associative Array Overview
-
Associative Array Implementation
- Using Association Lists for Associative Arrays
-
Using Hash Tables for Associative Arrays
- Advantages of Hash Tables
- Disadvantages of Hash Tables
- Understanding Hash Table Buckets
- Understanding Hash Table Collisions
- Understanding Chaining
- Understanding Object.GetHashCode
- Picking a Hashing Function
- Picking a Good Number of Buckets
- Implementing Your Internal Storage
- Getting Started
- Creating the Constructor
- Allowing Users to Associate Values with Keys
- Allowing Users to Remove Keys
- Adding Helper Methods and Properties
- Using the Associative Array Class
- Summary
-
3. Understanding Collections: Queues, Stacks, and Circular Buffers
- Queue Overview
- Queue Implementation
- Stack Overview
- Stack Implementation
- Circular Buffer Overview
- Circular Buffer Implementation
- Summary
-
II. .NET Built-in Collections
-
4. Generic Collections
- Understanding the Equality and Ordering Comparers
- Understanding Delegates, Anonymous Methods, and Lambda Expressions
- List(T) Overview
-
Using the List(T) Class
- Creating a List(T)
- Appending Items to a List(T)
- Traversing a List(T)
- Removing Items from a List(T)
- Inserting Items into a List(T)
- Sorting a List(T)
-
Searching a List(T)
- T Find(Predicate(T) match) and T FindLast(Predicate(T) match)
-
FindIndex and FindLastIndex
- int FindIndex(Predicate(T) match)
- int FindLastIndex(Predicate(T) match)
- int FindIndex(int startIndex, Predicate(T) match)
- int FindLastIndex(int startIndex, Predicate(T) match)
- int FindIndex(int startIndex, int count, Predicate(T) match)
- int FindLastIndex(int startIndex, int count, Predicate(T) match
- List(T) FindAll(Predicate(T) match)
- Using a Binary Search to Do the Searching
- Checking the Contents of a List
- Modifying the List
- LinkedList(T) Overview
-
Using the LinkedList(T) Class
- Creating a New LinkedList(T)
-
Adding to the LinkedList(T)
- void AddAfter(LinkedListNode(T) node, LinkedListNode(T) newNode)
- LinkedListNode(T) AddAfter(LinkedListNode(T) node, T value)
- void AddBefore(LinkedListNode(T) node, LinkedListNode(T) newNode)
- LinkedListNode(T) AddBefore(LinkedListNode(T) node, T value)
- LinkedListNode(T) AddFirst(T item)
- void AddFirst(LinkedListNode(T) node)
- LinkedListNode(T) AddLast (T item)
- void AddLast (LinkedListNode(T) node)
- Removing Nodes from the LinkedList(T)
- Obtaining Information on the LinkedList(T)
- Summary
-
5. Generic and Support Collections
- Queue(T) Overview
- Using the Queue(T) Class
- Stack(T) Overview
- Using the Stack(T) Class
- Dictionary(TKey,TValue) Overview
- Understanding Dictionary(TKey,TValue) Implementation
-
Using the Dictionary(TKey,TValue) Class
-
Creating a Dictionary
- Dictionary(TKey, TValue)()
- Dictionary(TKey, TValue)(IDictionary(TKey, TValue) dictionary)
- Dictionary(TKey, TValue)(IEqualityComparer(TKey) comparer)
- Dictionary(TKey, TValue)(int capacity)
- Dictionary(TKey, TValue)(IDictionary(TKey, TValue) dictionary, IEqualityComparer(TKey) comparer)
- Dictionary(TKey, TValue)(int capacity, IEqualityComparer(TKey) comparer)
- Adding Items to a Dictionary
- Removing Items from a Dictionary
- Retrieving Values from the Dictionary by Using a Key
- Checking the Dictionary
-
Creating a Dictionary
- BitArray Overview
- Using the BitArray Class
-
CollectionBase and DictionaryBase Overview
-
Using CollectionBase
- void OnValidate(object value)
- void OnClear() and void OnClearComplete()
- void OnInsert(int index, Object value) and void OnInsertComplete(int index, Object value)
- void OnRemove(int index, object value) and void OnRemoveComplete(int index, object value)
- void OnSet(int index, object oldValue, object newValue) and void OnSetComplete(int index, object oldValue, object newValue)
-
Using DictionaryBase
- void OnValidate(object key, object value)
- void OnClear() and void OnClearComplete()
- void OnGet()
- void OnInsert(Object key, Object value) and void OnInsertComplete(Object key, Object value)
- void OnRemove(Object key, Object value) and void OnRemoveComplete(Object key, Object value)
- void OnSet(Object key, object oldValue, object newValue) and void OnSetComplete(Object key, object oldValue, object newValue)
-
Using CollectionBase
- HashSet(T) Overview
-
Using the HashSet(T) Class
- Creating a HashSet(T)
- Adding Items to the HashSet(T)
- Removing Items from a HashSet(T)
-
Performing Set Operations on a HashSet(T)
- void IntersectWith(IEnumerable(T) other)
- bool IsProperSubsetOf(IEnumerable(T) other)
- bool IsProperSupersetOf(IEnumerable(T) other)
- bool IsSubsetOf(IEnumerable(T) other)
- bool IsSupersetOf(IEnumerable(T) other)
- bool Overlaps(IEnumerable(T) other)
- void UnionWith(IEnumerable(T) other)
- void ExceptWith(IEnumerable(T) other)
- bool Contains(T item)
- void TrimExcess()
- Sorted Collections Overview
- Summary
-
4. Generic Collections
-
III. Using Collections
-
6. .NET Collection Interfaces
- Enumerators (IEnumerable and IEnumerator) Overview
- Adding Enumeration Support to Classes
- ICollection and ICollection(T) Overview
- Adding Collection Support to Classes
- IList and IList(T) Overview
- Adding IList(T) and IList Support to Classes
- IDictionary(TKey,TValue) Overview
- Adding Key/Value Pair Support to Classes
- Summary
- 7. Introduction to LINQ
-
8. Using Threads with Collections
- What Is a Thread?
- What Is Thread Synchronization?
- .NET Framework Tools for Synchronization
- Adding Synchronization Support to Your Collection Classes
- SyncRoot vs. the Synchronized Wrapper Class (IsSynchronized)
- Using the Monitor Class
- Using the ReaderWriterLockSlim Class
- Implementing a Synchronized Wrapper Class
- Handling Collection Changes While Enumerating
- Synchronized Collection Classes
- Summary
- 9. Serializing Collections
-
6. .NET Collection Interfaces
-
IV. Using Collections with UI Controls
- 10. Using Collections with Windows Form Controls
- 11. Using Collections with WPF and Silverlight Controls
- A. About the Author
- Index
- About the Author
- Copyright
Product information
- Title: Developer’s Guide to Collections in Microsoft® .NET
- Author(s):
- Release date: September 2011
- Publisher(s): Microsoft Press
- ISBN: 9780735664791
You might also like
article
Reinventing the Organization for GenAI and LLMs
Previous technology breakthroughs did not upend organizational structure, but generative AI and LLMs will. We now …
book
XAML Developer Reference
Your expert guide to designing and building dynamic user interfaces Sharpen your application design and development …
book
ASP.NET Site Performance Secrets
Simple and proven techniques to quickly speed up your ASP.NET website Speed up your ASP.NET website …
book
Programming in the .NET Environment
is the software developer's guide to the .NET Framework. The authors describe Microsoft's vision for distributed …