I think you do not really want a two dimensional array in this case.
What you really want is an array of a tuple.
using System;
namespace tuple_array
{
using Item = Tuple<String,String[]>;
class Program
{
static void Main(string[] args)
{
Item[] foodarray = new Item[] {
new Item("onion", new string[]
{ "strawberry", "banana", "grape" })
};
foreach (var item in foodarray) {
var (f,fs) = item;
var foo = string.Join(",", fs);
Console.WriteLine($"[{f},[{foo}]]");
}
}
}
}
It looks somewhat clumsy in C#, the F# version is much more terse and pretty:
type A = (string * string []) []
let a : A = [| "onion", [| "strawberry"; "banana"; "grape" |] |]
printfn "%A" a
objectand check / cast appropriately to eitherstringorstring[].structor a class for that, why do you need an array?