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.
Verifying Critical Parameters
|
371
argument was passed in that was outside of a valid acceptable range. This excep-
tion is used mainly with numeric values. The
InvalidEnumArgumentException
indicates that an enumeration value was passed in that does not exist in that
enumeration type.
Throw a
FormatException when an invalid formatting parameter is passed in as a
parameter to a method. This technique is mainly used when overriding/over-
loading methods such as
ToString that can accept formatting strings, as well as
in the parse methods on the various numeric types.
Throw
ObjectDisposedException when a property, indexer, or method is called
on an object that has already been disposed.
Many exceptions that derive from the
SystemException class, such as
NullReferenceException, ExecutionEngineException, StackOverflowException,
OutOfMemoryException, and IndexOutOfRangeException are thrown only by the
CLR and should not be explicitly thrown with the
throw keyword in your code.
7.1 Verifying Critical Parameters
Problem
You have a method, property, or indexer that requires the correct value or set of val-
ues to be passed in to it (e.g., cannot be
null, must be within a numeric range or a set
of numeric ranges, the enumeration value must be a valid value in the enumeration).
If an incorrect value
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