0

Is there any way I can create a 2d array using the variables in the below struct please ?

public struct Marks
{
    public int midyearly;
    public int finalyear;
    public Marks(int midyearly, int finalyear)
    {
        this.midyearly = midyearly;
        this.finalyear = finalyear;
    }

    public override string ToString()
    {
        return "(" + midyearly + "," + finalyear + ")";
    }
}
Steve Czetty
  • 6,147
  • 9
  • 39
  • 48

1 Answers1

0

If you have a Marks[] then you can create a 2D array like this:

Marks[] marks = ...;
var items = marks.Select(mark => new[] {mark.midyearly, mark.finalyear});

This will give you an int[][].

But it's hard to tell if that's what you want.

Drew Noakes
  • 300,895
  • 165
  • 679
  • 742