Generics in VB.NET


Saw these cups knocking about recently.


I like the implementation of Generics in VB.NET. When you describe a generic type in C# or Java, and you have a type Database<T> you say a "database of T". VB.NET takes this further, the syntax is just Database(of T).

Generics allow you to resuse a class or a method for multiple types that need the same abstract functionality. A good example is two entities in your system that need to be persisted. The entities have different logic and a different reason to exist but they both need to be saved to a database. In this case you can implement the same functionality twice or reuse one class but allow it to be flexible enough to handle both entities.

I saw the picture of that cup knocking about on Twitter recently then I saw people wearing TShirts at a recent Scott Gu talk on Microsoft Azure. I would like to get my hands on an official one!


SHARE

Dom Finn

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment