Skip to Main Content
C# Cookbook, 2nd Edition
book

C# Cookbook, 2nd Edition

by Jay Hilyard, Stephen Teilhet
January 2006
Intermediate to advanced content levelIntermediate to advanced
1184 pages
43h 23m
English
O'Reilly Media, Inc.
Content preview from C# Cookbook, 2nd Edition
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Reversing the Contents of a Sorted List
|
241
The result of using a nullable type in an expression is a null if any nullable type is
null. However, if none of the nullable types is null, the operation is evaluated as it
normally would be. If
DBInt, for example, is set to null, the value placed in Result
will also be null.
See Also
See the “Nullable<T> Generic Class” and “Using Nullable Types” topics in the
MSDN documentation.
4.8 Reversing the Contents of a Sorted List
Problem
You want to be able to reverse the contents of a sorted list of items while also main-
taining the ability to access them in both array and list styles like
SortedList and the
generic
SortedList<T> classes provide. Neither SortedList nor SortedList<T> pro-
vides a direct way to accomplish this without reloading the list.
Solution
Use the ReversibleSortedList<TKey,TValue> class provided for you here. Reversible-
SortedList<TKey,TValue>
is based on the original SortedList<TKey,TValue> class so
that all of the same functionality is preserved, with the additional bonus of being able
to reverse the order of the list easily.
After instantiating a
ReversibleSortedList<TKey,TValue>, the key of which is an int
and the value of which is a string, a series of unordered numbers and their text rep-
resentations are inserted into the list. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C# Cookbook

C# Cookbook

Stephen Teilhet, Jay Hilyard
C# Cookbook

C# Cookbook

Joe Mayo
Head First C#, 4th Edition

Head First C#, 4th Edition

Andrew Stellman, Jennifer Greene

Publisher Resources

ISBN: 0596100639Supplemental ContentCatalog PageErrata