-2
给我请指教。我该怎么办直接从列表转换[串[]]列出[INT []或转换到我的例如定义对象FreightInTeritory列表收集转换
这里被转换代码列表列出:
List<string[]> obj = new List<string[]>();
obj.Add(new string[]{"1", "2", "3", "4"});
obj.Add(new string[] { "1", "2", "3", "4" });
obj.Add(new string[] { "1", "2", "3", "4" });
obj.Add(new string[] { "1", "2", "3", "4" });
var l1 = obj.ConvertAll(s=>Int32.Parse(s.ToString()));
以及如何我这样做可以从类对象(FreightInTeritory)转换为例如列表[字符串[]非常感谢你.....
public class FreightInTeritory
{
private string territoryDescription;
private double freight;
public string TerritoryDescription { get; set; }
public string Freight {get; set;}
}
关于你的第一个问题,你几乎自己回答了这个问题。剩下的就是将'l1'从'int []'转换为'List'(不是'List [int []]'btw。)。可以用'新列表(l1)'或'l1.ToList()'。 (后面的选项需要'使用System.Linq;'指令。) –
stakx
2014-10-04 18:47:51
对于化身。 – DarthVader 2014-10-04 18:51:37