Link to home
Start Free TrialLog in
Avatar of CipherIS
CipherISFlag for United States of America

asked on

C# Convert System.Array to a List keeping all indexes in the List from System.Array.

I'm converting a System.Array to a list.  Reason I'm doing this is because I can't check the values I want with _excelvalues[1,5].
System.Array excelvalues = (System.Array)_excelsheet.get_Range("A" + index.ToString(), 
    "K" + index.ToString()).Cells.Value;

Open in new window

var values = excelvalues.OfType<object>().Select(o => o.ToString()).ToList();

Open in new window

How do I convert BUT migrate everything from the System.Array to the list.  If it is empty the length of the List does not match the System.Array and I want it to always match.

Example:
System.Array[1,12] -> List[12]

Right now I can get System.Array[1,12] -> List[6]
ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial