Pass a List of Series to SetSeries

I am using DotNet.Highcharts in conjunction with Visual Studio 2010. I have created an array of Series:

List<Series> allSeries = new List<Series>();

I then looped through a database and added several different Series. Then I created a Highchart and need to add the allSeries list to it. I have the code below that I used to create a Series one at a time. How can I take the allSeries list and pass it to SetSeries?

.SetSeries(new[]
           {
               new Series { Name = "Combiner 2", Data = new Data(myData2) },
               new Series { Name = "Combiner 3", Data = new Data(myData3) }
           });

Answers


if I am left to assume that the myData2 and myData3 objects are contained in or could be extracted from allSeries, then you should be able to do something like this:

.SetSeries(allSeries.Select(s=> new Series { Name = s.Name, Data = s.Data }));

EDIT: If set series isn't looking for an IEnumerable<Series> but instead needs Object[] or Series[], then you could do this:

//casts series elements to object, then projects to array
.SetSeries(allSeries.Select(s=> (object)new Series { Name = s.Name, Data = s.Data }).ToArray());

or maybe this:

//projects series elements to array of series
.SetSeries(allSeries.Select(s=> new Series { Name = s.Name, Data = s.Data }).ToArray());

it all depends on what the method signature for SetSeries is.


Need Your Help

What is the difference between an interface and abstract class?

oop interface abstract-class

What exactly is the difference between an interface and abstract class?

Help with <key> event in python Entry widget

python events widget tkinter

I'm writing some code in python and I'm having trouble when trying to retrieve content of an Entry widget.