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?
Return an array of
intlike this:You can also implicitly type the array – the compiler will infer it should be
int[]because it contains onlyintvalues: