I think I have asked this in the context of C++ (Can't find it in my question history!!) in the past and the solution was to use a template function. As C++ template resolve at compile time, it works. But for C#, it doesn't.
public Hashtable ConvertToHashtable<T>(T source) where T has an index operator
{
Hashtable table = new Hashtable();
table["apple"] = source["apple"];
return table;
}
One usage at the moment is to convert the result in OleDbReader to hashtable, but I am forseeing the need for more source types soon.