I would like to add a string array to a list of string arrays I have predefined. Here is a minimal working example:
using System;
using System.Collections.Generic;
public class Test
{
static void Main()
{
List<string[]> listOfStringArrays = new List<string[]>();
listOfStringArrays.Add({"hello", "world"});
}
}
Unfortunately, the aboce example throws errors like the following:
C:\Users\bm\desktop\temp\csharp_codility\add-string-array-to-list\Program.cs(9,32): error CS1
026: ) expected [C:\Users\bm\desktop\temp\csharp_codility\add-string-array-to-list\console-cu
stom.csproj]
C:\Users\bm\desktop\temp\csharp_codility\add-string-array-to-list\Program.cs(9,32): error CS1
002: ; expected [C:\Users\bm\desktop\temp\csharp_codility\add-string-array-to-list\console-cu
stom.csproj]
002: ; expected [C:\Users\bm\desktop\temp\csharp_codility\add-string-array-to-list\console-cu
stom.csproj]
C:\Users\bm\desktop\temp\csharp_codility\add-string-array-to-list\Program.cs(9,40): error CS1
513: } expected [C:\Users\bm\desktop\temp\csharp_codility\add-string-array-to-list\console-cu
stom.csproj]
C:\Users\bm\desktop\temp\csharp_codility\add-string-array-to-list\Program.cs(9,49): error CS1
002: ; expected [C:\Users\bm\desktop\temp\csharp_codility\add-string-array-to-list\console-cu
stom.csproj]
C:\Users\bm\desktop\temp\csharp_codility\add-string-array-to-list\Program.cs(9,50): error CS1
513: } expected [C:\Users\bm\desktop\temp\csharp_codility\add-string-array-to-list\console-cu
stom.csproj]
The build failed. Fix the build errors and run again.
What is wrong with my code? How can I fix it?