How to return an array literal in C#
c#
Solution
Return an array of `int` like this:
return new int [] { 0, 0, 0 };
You can also implicitly type the array - the compiler will infer it should be `int[]` because it contains only `int` values:
return new [] { 0, 0, 0 };
Problem
I'm trying the following code. The line with the error is pointed out. ``` int[] myfunction() { { //regular code } catch (Exception ex) { return {0,0,0}; //gives error } } ``` How can I return an array literal like string literals?