0

Can anyone explain to me the difference between the two arrays?

string[] adminUsers = { "user1", "user2","user3" };
                    VS
var adminUsers = new string[] { "user1", "user2","user3" };

Which is the better way to declare an array?

1 Answer 1

2

They are the same. MSDN states "You can also omit the new operator"

Sign up to request clarification or add additional context in comments.

1 Comment

As a bonus note, this question and answer is the same for Java, except for var.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.