# Arrays. What is correct?

**URL:** <https://forum.codewithmosh.com/t/arrays-what-is-correct/1138>\
**Category:** C#\
**Created:** [December 5, 2020, 10:26am UTC](https://forum.codewithmosh.com/t/arrays-what-is-correct/1138 "2020-12-05T10:26:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![R0k0](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/r0k0/32/368_2.png) [@R0k0](https://forum.codewithmosh.com/u/R0k0)\
**Post date:** [December 5, 2020, 10:26am UTC](https://forum.codewithmosh.com/t/arrays-what-is-correct/1138/1 "2020-12-05T10:26:40Z")

</div>

Hi,  
why sometimes need to declare number of arrays places and other times not?  
What is correct?

var arr = new int[3] {1,2,3};  
or  
var arr2 = new int[] {1,2,3};

---

<div class="post-metadata">

**Author:** ![SAM](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/sam/32/167_2.png) [@SAM](https://forum.codewithmosh.com/u/SAM)\
**Post date:** [December 5, 2020, 10:44am UTC](https://forum.codewithmosh.com/t/arrays-what-is-correct/1138/2 "2020-12-05T10:44:03Z")

</div>

Both are correct. You need to supply the array size if the compiler can’t infer it. If you provide an array initializer the compiler can infer the size from the number of values you provide there. If you don’t provide an initializer you need to specify the size explicitly.
