You are currently viewing Create A String Array in C# – Declare and fill object

Create A String Array in C# – Declare and fill object

Sample Code:

class Program
{
static void Main()
{
// String arrays with 3 elements.
string[] arr1 = new string[] { “one”, “two”, “three” };
string[] arr2 = { “one”, “two”, “three” };
var arr3 = new string[] { “one”, “two”, “three” };

string[] arr4 = new string[3];
arr4[0] = “one”;
arr4[1] = “two”;
arr4[2] = “three”;
}
}

Resources:

https://www.dotnetperls.com/array