0

我有三个数据结构,

Tuple<string, string> parentid = null;
var subids = new List<Tuple<int, int>>();
Tuple<string, string> dname = null;

ArrayList al = new ArrayList();
al.add(parentid);
al.add(subids);
al.add(dname);

我调用了一个函数,它返回一个ArrayList包含这 3 个数据结构的函数。

例如

ArrayList al = category.getTree();

现在我想将数据结构传递给另一个方法

string option = category.printOption(al[0], al[1], al[2], 0);

printOption代码:

public string printOption(Tuple<string, string> parents, List<Tuple<int, int>> subids, Tuple<string, string> dname, int indent)

但是有一个错误:

最好的重载方法.......

有谁知道问题是什么?

4

2 回答 2

0

ArrayList存储对象,因此要使用内容,您需要将要使用的每个对象转换为正确的类型:

string option = category.printOption((Tuple<string, string>)al[0],
    (List<Tuple<int, int>>)al[1], (Tuple<string, string>)al[2], 0); 
于 2012-10-16T03:21:45.750 回答
0
string option = category.printOption((add your cast here) al[0], ( List< Tuple < int, int>>) al[1], (and here) al[2], 0);
于 2012-10-16T03:23:39.323 回答