![]() Then the collection can be used to populate generic collection types.ĬA1012: Abstract types should not have constructorsĬonstructors on abstract types can be called only by derived types. To broaden the usability of a collection, implement one of the generic collection interfaces. ![]() If an enumeration that has the FlagsAttribute attribute applied defines a zero-valued member, its name should be "None" to indicate that no values have been set in the enumeration.ĬA1010: Collections should implement generic interface A nonflags-attributed enumeration should define a member by using the value of zero so that the default value is a valid value of the enumeration. The default value of an uninitialized enumeration, just as other value types, is zero. However, if more than two type parameters exist, the difficulty becomes too great for most users. It is usually obvious with one type parameter, as in List, and in certain cases that have two type parameters, as in Dictionary. The more type parameters a generic type contains, the more difficult it is to know and remember what each type parameter represents. NET Framework 2.0.ĬA1005: Avoid excessive parameters on generic types The generic collections that are designed for inheritance should be exposed instead.ĬA1003: Use generic event handler instancesĪ type contains a delegate that returns void, whose signature contains two parameters (the first an object and the second a type that is assignable to EventArgs), and the containing assembly targets Microsoft. Therefore, List does not contain any virtual members. )>) is a generic collection that is designed for performance, not inheritance. A class that declares an IDisposable field indirectly owns an unmanaged resource and should implement the IDisposable interface. In these two cases, the syntax for specifying the type argument is different and easily confused.ĬA1001: Types that own disposable fields should be disposableĪ class declares and implements an instance field that is a System.IDisposable type, and the class does not implement IDisposable. When a generic instance member that does not support inference is called, the type argument must be specified for the member. ![]() When a static member of a generic type is called, the type argument must be specified for the type. CA1000: Do not declare static members on generic types ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |