Is it right to use inheritance instead of merging names in C #?

In other words, is it correct to use:

public class CustomerList : System.Collections.Generic.List<Customer>
{
    /// supposed to be empty
}

instead:

using CustomerList = System.Collections.Generic.List<Customer>

I would prefer to use the first approach, because I just defined the CustomerList once, and every time I need a list of customers, I would always use the same type. On the other hand, using an approach with a name alias not only forces me to redefine it everywhere, but every other alias can be provided every time someone wants to use it (think of a large command), and therefore are less readable.

Note that the intention in this case will never extend the class, just to create an alias.

+5
9

. :

List<Customer> 

. :

CustomerList

, CustomerList, . , , - .

+6

, , -. , , ?

List<Customer> customerList = new List<Customer>();
+11

, . ; . , , , List, , .

List<Customer>, , , . List<Customer> IList<Customer> ICollection<Customer>, .

, CustomerList, ICollection<Customer> IList<Customer> .

+4

. , System.Collections.ObjectModel.Collection <T> API ( <T> ).

, :

Collection <T> API .

Collection <T> API- .

+3

aliasing/typedefing , , .

, .

+3

" ".

, , - .

, .

+1

, . , - .

, - .

List<Customer> .

+1

. List, :

List<Customer> customerList = new List<Customer>();

, .

- , , IEnumerable. (, "foreach" ), .

+1

, , . , , . , . ( , !)

+1

All Articles