Collection snippet


Often, I need to create lists of data. It is obviously possible to use generic lists (List<T>), but they are not easily expandable. For example, it is not possible to remove the Add and Remove methods, it is also difficult to add an event OnChanged that would detect when a property of object (T) change.

So, we must implement our collection that inherits from CollectionBase and IEnumerable<T> to allow LINQ queries.

To simplify the creation of these collections, I’ve prepared a Snippet to include in Visual Studio (Tools / Code Snippets Manager / Import). You can easily use it (Ctrl+K, Ctrl+X) and choose the name of the class… all methods are automatically adapted.

1. Select the ClassCollection snippet (Ctrl+K, Ctrl+X).

2. Write you class name (Employee, Department, etc).

3. And use it.

Remarks: The snippet diagram class is.

File: Download the snippet ClassCollection here.

Advertisements
Tagged with: , , ,
Posted in General, Tips and others

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow me
   RSS Feed    Twitter    Linked In

Write you email address to subscribe at this blog and to receive new posts by mail.

Join 565 other followers

Who I am?






%d bloggers like this: