Freigeben über


Adding Values to Enumerations 

The following guideline discusses introducing a potentially breaking change for users of your libraries. If you add values to a previously shipped enumeration, existing application code might not be robust enough to gracefully handle the new values.

Consider adding values to enumerations despite a small compatibility risk.

This guideline is relevant when you expect to be shipping more than one version of your library. To minimize the code that breaks due to adding values to an existing enumeration, you can implement new members that return the full set of values and mark the existing members (that return the original set of values) using the ObsoleteAttribute attribute. If breaking changes are not acceptable, you can define a new enumeration and the associated members that work with it, and mark the existing members and enumeration as obsolete.

Portions Copyright 2005 Microsoft Corporation. All rights reserved.

Portions Copyright Addison-Wesley Corporation. All rights reserved.

For more information on design guidelines, see the "Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries" book by Krzysztof Cwalina and Brad Abrams, published by Addison-Wesley, 2005.

See Also

Concepts

Enumeration Design
Designing Flags Enumerations

Other Resources

Type Design Guidelines
Design Guidelines for Developing Class Libraries