相关疑难解决方法(0)

Convert Array to custom object list c#

I have a array:-

private string[][] barValues = new string[][] { new string[]{ "1.9", "5.8", "4.8", "Since Inception", "24-Jan 2014 to 24 Jun 2014" },
                                                new string[]{"1.2", "16.5","9.8", "Year to date","01-Apr 2014 to 24-Jun 2014" }, 
                                                new string[]{"11.6","28.8","23.5","Last quarter","01-Jan to 24-Jun 2014"} };
Run Code Online (Sandbox Code Playgroud)

I want to convert this array into my custom list :-

List<Portfolio> list = new List<Portfolio>();
Run Code Online (Sandbox Code Playgroud)

I tried doing :-

List<Portfolio> list=myArray.Cast<Portfolio>().ToList();
Run Code Online (Sandbox Code Playgroud)

But I get a error:-

System.InvalidCastException: Cannot cast from source type to destination type.

How …

c# arrays custom-lists

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

arrays ×1

c# ×1

custom-lists ×1