Returning ‘anonymous’ array

(Perhaps not anonymous, but… well, you'll see)

I have a function that returns a string array. I want to do this:

private string[] myFunction(string arg1, string arg2){ return {arg1, arg2}; } 

But that doesn't work. But this does:

private string[] myFunction(string arg1, string arg2){ string[] myArray = {arg1, arg2}; return myArray; } 

Do you see what I'm trying to do and is there a way to do it? Maybe I'm playing with javascript too much.

by ryokimball via /r/csharp

Leave a Reply