Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将数据结构作为参数传递_C#_Asp.net - Fatal编程技术网

C# 将数据结构作为参数传递

C# 将数据结构作为参数传递,c#,asp.net,C#,Asp.net,我有三个数据结构 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); 现在我想把数据结构传递给另一个方法

我有三个数据结构

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);
现在我想把数据结构传递给另一个方法

string option = category.printOption(al[0], al[1], al[2], 0);
打印选项
代码:

public string printOption(Tuple<string, string> parents, List<Tuple<int, int>> subids, Tuple<string, string> dname, int indent)
公共字符串打印选项(元组父项、列表子ID、元组dname、int缩进)
但有一个错误:

最好的重载方法


有人知道问题出在哪里吗?

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

string option = category.printOption((Tuple<string, string>)al[0],
    (List<Tuple<int, int>>)al[1], (Tuple<string, string>)al[2], 0); 
string option=category.printOption((元组)al[0],
(列表)al[1],(元组)al[2],0);
string option=category.printOption((在此处添加强制转换)al[0],(List)al[1],(此处)al[2],0);

完整的错误消息是什么,发生在哪里?
string option = category.printOption((Tuple<string, string>)al[0],
    (List<Tuple<int, int>>)al[1], (Tuple<string, string>)al[2], 0); 
string option = category.printOption((add your cast here) al[0], ( List< Tuple < int, int>>) al[1], (and here) al[2], 0);