我脑子里死了; 我根据特定的类(c1,c2,c3 ......)定义了几个List'.我有一个方法来处理这些列表上的信息.我想要做的是传递特定列表,但让方法接受通用列表,然后通过typeof确定要执行的具体工作.我知道它可能,但我似乎无法在方法方面获得正确的语法.所以,例如:
List<c1> c1var;
List<c2> c2var;
List<c3> c3var;
some_method(c1var);
some_method(c2var);
some_method(c3var);
class some_thing
some_method(List<> somevar)
if typeof(somevar).name = x then
esle if typeof(somevar).name = y then....
Run Code Online (Sandbox Code Playgroud)
如何设置方法的参数列表?
谢谢R.桑德斯