Posts

Showing posts from July, 2016

C# Generics

Image
In this blog I will very briefly discuss some of the concepts of generics. I also want to mention that generics is a large topic so please see MSDN for reference. I will try to deliver some general concepts about generics. What are Generics? Generics allow us to write classes, structures, methods, interfaces or delegate in such a way that they operate on the type of data specified in the parameter <T> . So for example, we write a general code for a class and it can perform that functionality on different types of data mentioned in the type parameter. Can’t we do the same with object class? Well not in all cases. Generics allow us to write a general code which will compile as if it were written on the type we specified in parameter. Also, if we try to get this functionality with object class, there is a lot of burden in doing so, such as downcasting every time we need to operate on specific type, boxing & unboxing can be an overhead on processing. Why