I have a method, accepting a Hashtable (yes I know, it’s outdated..) as argument:
public static LuaTable HashtableToLuatable(Hashtable t, int depth = 1)
This works correctly.
Now I’d like to accept an ArrayList as first parameter as well, so you can let ‘t’ have the value of both a Hashtable and an ArrayList. Currently I have copy-pasted the method two times, like this:
public static LuaTable ArraylistToLuatable(ArrayList t, int depth = 1)
The rest is exactly the same.
I think there’s a way to merge this.
Both classes implement the ICollection interface, so if your ‘common code’ will work against the definition of the ICollection interface, you could use that for your parameter type.