private string[] GetRoles()
{
string[] foo = {"Test"};
return foo;
}
In the example above you are creating a new string[] array and then initialising it with one element called "Test".
private string[] GetRoles()
{
return {"Test"};
}
In this example you have created a method that expects to return a string array. However, you are at no point creating a new string array[]* object. Before you can add elements to an array you need to first create it. You are basically trying to returns elements from a non-existent array, which is why it fails.
You could argue the compiler could create the array for you, but it doesn't do that in your first example, so why expect it to do it in the second?