I am trying to create a jagged array of 10 by 10 using Linq and I want to populate it (for now) all with the same letter (not character). However, I am having trouble figuring out how to populate it in the same Linq statement.
I currently have (similar to Initialize a Jagged Array the LINQ Way):
public static string[][] computerBoard = new string[10][]
.Select(x => new string[10])
.ToArray();
But that creates array of null strings. How to modify it to set all elements to the same value as "A"? Or should I use a double for loop to populate it?
I have tried doing this:
public static string[][] computerBoard = new string[10][]
.Select(x => new string[10]
.Select(y => y = "/*my letter*/"))
.ToArray();
but it gives me an error:
CS0226: Cannot implicitly convert type 'System.Collections.Generic.Ienumerable[]' to 'string[][]'. An explicit conversion exists (are you missing a cast?)
I think this is what you're going for: