when i have to use and when i shld not use generics ?
-
Check this one. http://msdn.microsoft.com/en-us/library/ms172194.aspx[^] :)
Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Simplify Code Using NDepend
Basics of Bing Search API using .NET
Microsoft Bing MAP using Javascript -
A quick rule of thumb - if your application is doing boxing/unboxing and there are common features on a class, possibly based off an interface, then you should really consider using generics.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
-
You never have to.
-
Wherever you can - Generics is a very broad subject and it has many applications. It allows your code to work with more than one type at runtime with type safety. If you use a generic List instead of an object array, there's no boxing/unboxing happening at runtime which actually improves performance by orders of magnitude. And there are millions of advantages. I would suggest that you go over the articles on the Internet to learn generics. Initially it may seems to be a complicated technology, but once you start appreciating its purpose, thing will be easy for you. Essential C# 2.0: Chapter 11: Generics[^]