You are on page 1of 2

Bulaga, Debbie Mae C.

 BSIT 211
What is Array in C#?
Arrays are using for store similar data types grouping as a single unit. We can access
Array elements by its numeric index. The array indexes start at zero. The default value of
numeric array elements are set to zero, and reference elements are set to null.

 Give two programs of C# using Array

 C# Program that initialize string arrays

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";
}
}

 using System;

class Program
{
static void Main()
{
// Three-element array.
int[] array = { -5, -6, -7 };
// Pass array to Method.
Console.WriteLine(Method(array));
}
/// <summary>
/// Recieve array parameter.
/// </summary>
static int Method(int[] array)
{
return array[0] * 2;
}
}

Output: 10

WHAT IS ONE DIMENSIONAL?

A one dimensional array is a section of memory that contains structs or built in types or
pointers to something. This is usually accessed through a pointer, but it can be allocated
directly on the stack.

WHAT IS MULTIDIMENSIONAL?

A multidimensional array continues the 2 dimensional model.a basic understanding of


pointers is required to understand arrays in C or C++, and is helpful in any language.

You might also like