The easy way:
private void TestHit()
{
var intlist = new List<int> {2, 3, 7};
var stringlist = new List<string> {"A", "B", "C"};
Hit(intlist);
Hit(stringlist);
}
private void Hit<T1>(List<T1> theList)
{
if (theList == null) throw new ArgumentNullException("theList");
if (theList.Count == 0) throw new ArgumentOutOfRangeException("theList");
Console.WriteLine(theList[0]);
}
The method 'Hit declares it uses one generic parameter by putting the place-holder name "T1" in angle-brackets after the method name. In the parameter list a generic List of whatever 'T1 will become at run-time, as the method is invoked, is defined. Using "T1" is a common convention, but you could use any non-reserved name for it; if you wanted to write:
private void Hit<TypeToBeDetermined>(List<TypeToBeDetermined> theList);
That would be just fine, but ... verbose, indeed.