# How can I plot Arrays in C Sharp? • ### Question

• I need to plot Arrays in C#; I'm very new to C# and I don't know the best way to do that. can you please tell me how can I plot y1 and t1 against each other?

here is my codes:

```using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Research.Oslo;

namespace odestiff
{
class Program
{
static void Main(string[] args)
{

//solve the equations with Gear method
var sol = Microsoft.Research.Oslo.Ode.GearBDF(
0,
new Vector(2, 0),
(t, x) => new Vector(
x,
1000 * (1 - x*x) * x - x)).TakeWhile(p => p.T <= 3000).ToArray();  //define the time span

//// put results in an array
double[] y1 = sol.Select(p => p.X).ToArray();
double[] t1 = sol.Select(p => p.T).ToArray();

}
}
}
```

Wednesday, November 22, 2017 4:59 AM

• Hi Mahan,

In Visual c#, use Chart control from Toolbox, and the code are as follows,

In your case, the following expression

is substituted by

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;

namespace WindowsFormsPlotArray
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
Random rdn = new Random();
for (int i = 0; i < 50; i++)
{
}
chart1.Series["Series1"].ChartType = SeriesChartType.FastLine;
chart1.Series["Series1"].Color = Color.Red;
}
}
}

• Edited by Wednesday, November 22, 2017 5:44 AM
• Marked as answer by Thursday, November 23, 2017 7:39 AM
Wednesday, November 22, 2017 5:31 AM

### All replies

• Hi Mahan,

In Visual c#, use Chart control from Toolbox, and the code are as follows,

In your case, the following expression

is substituted by

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;

namespace WindowsFormsPlotArray
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
Random rdn = new Random();
for (int i = 0; i < 50; i++)
{
}
chart1.Series["Series1"].ChartType = SeriesChartType.FastLine;
chart1.Series["Series1"].Color = Color.Red;
}
}
}

• Edited by Wednesday, November 22, 2017 5:44 AM
• Marked as answer by Thursday, November 23, 2017 7:39 AM
Wednesday, November 22, 2017 5:31 AM
• Thanks a lot! It's Work
Appreciate that
Thursday, November 23, 2017 9:31 AM