Tuesday, June 12, 2012

Best Practices: Generic lists

ArrayList and Collection class can store Object data.

As Objects are base class for all types, you can store any kind of data within ArrayList and Collections. But mostly we will store specific type of data within collections. So we probably will use casting while retrieving data, which will impact the performance. To avoid this, we can use Generic class such as List<T> and Dictionary<K,V>

Tuesday, June 05, 2012

Generics- Introduction

Generics is the concept of applying types to members such as fields, properties and method signatures when user access it and not when the class designer defines the class.

 

Advantages

  • Performance
  • No need to create similar classes that one varies by member types

 

Introduced in .Net framework 2.0