List<t> to array (in separate class)

Below is the basic setup of my program thus far. 2 classes. One to keep track of the OrderInfo and the other to do the WebRequest processes and gather the information.

I know that order.FullCashValues = Details.ToArray(); will put all the values of my Details List into the FullCashValues object[]. But i just want the first 6 items to go into that object and the rest of the objects in the Details list to go into the AssessedValues object[].

Any help?

    Public Class OrderInfo
    {
    public object[] FullCashValues {get;set;}
    public object[] AssessedValues {get;set;}
    }

Public Class WebRequests
{
    public static List<List<object>> Main_Process(OrderInfo order)
    {
    //returns a list of values taken from the url
    List<object> Details = DetailsPage(url1, ParcelNumber);

    //Details[0] through Details[5] should go into 
    //FullCashValues

    //Details[6] through Details[11] should go into
    //AssessedValues
    }
    }

Answers


You can use LINQ's Skip and Take methods to split the list (both methods are available in .NET 3.5).

FullCashValues = Details.Take(6).ToArray();
AssessedValues = Details.Skip(6).ToArray();

Need Your Help

.NET MVC - Collection properties should be read only Change to be read-only by removing the property

c# asp.net-mvc code-analysis

I have a controller that uses two classes. One is called IndexModel and the other IndexViewModel.

Resize JTextArea

java swing jpanel jtextarea

What I'm trying to do is really simple, but I can't find a solution to it.