Cloud Training (Online)




Different Ways of Declaring and defining an Array in C#

There are many different ways in which one can declare an array in C# .

In this blog post , I will list out some of the ways in which one can declare an array .

Different Ways of Declaring and defining an Array in C#

Technique #1

string[] moviesArray = new string[2];

moviesArray[0] = "Jilla";

moviesArray[1] = "Veeram";

Technique #2

string[] moviesArray = new string[2] { "Jilla", "Veeram" };

Technique #3

string[] moviesArray = { "Jilla", "Veeram" };

Which one of the above ways of declaring and defining and array do you use ?

Senthil Kumar B
Senthil Kumar is a former Microsoft MVP (Most Valuable Professional). He is a Co-Author of the book "Windows 10 Development Recipes using JavaScript and CSS" for Apress Publication. He is a technical presenter, blogger, mentor and a Geek.  Senthil is a regular speaker is various local user groups. He has presented at conferences like Great Indian Developer Summit (GIDS) & Microsoft DevCamps. You can reach out to him via his Twitter handle @isenthil.