In this post I will talk about another nifty feature that C# has offered for a while now, Generics. You probably won't run into Generics on a day to day basis. If you work alot with data collections however, you might find them useful at some point. I've probably personally used Generics twice on my own personal websites, and they come in extremely handy and can save alot of time and help avoid writing too much repetitive code. If you're familiar with C++, Generics are somewhat comparable to Templates in the old STL.
What are Generics?
With Generics you can postpone setting parameter types to a function or class until that function or class has been instantiated by the client. So for example, let's say that we have a function that performs a generic operation on a set of parameters being passed in.
public class SampleClass
public void DoWork(int data)
// do something with the data, anything
That's pretty straightforward. But now let's assume that we want to have the same operation run but instead of an integer, it takes in a decimal value.
. . .