如何将多阵列之一转换为类

时间:2017-10-04 08:25:42

标签: c# arrays class

我遇到与this example类似的问题。 但不同的是,我的是一个var,在这个例子中是一个类。

var debugExe = requete.List();

我试过这个:

 var tester = debugExe[0] as IEnumerable<Client>;
 IList<Client> temp = tester.ToList<Client>();

我的var tester为null,debugExe不为null。

debuxExe的类型:enter image description here

List()返回2维数组。

1 个答案:

答案 0 :(得分:0)

要使用实现IEnumerable的内容填充对象,您可以尝试:

var temp = new List<Client>(debugExe);

通过这种方式,您将拥有一个空的但可以排队的列表。