0% found this document useful (0 votes)
29 views2 pages

Bulaga, Debbie Mae C. BSIT 211 What Is Array in C#?: Arr4 (1) "Two"

The document discusses arrays in C#. It defines an array as a data structure that stores similar data types together as a single unit. Array elements can be accessed by their numeric index, which starts at 0. The document provides two examples of C# programs that initialize string arrays in different ways and an example of a program that passes an integer array as a parameter to a method. It also defines one-dimensional arrays as sections of memory containing data accessed through a pointer and multi-dimensional arrays as continuing the two-dimensional model.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views2 pages

Bulaga, Debbie Mae C. BSIT 211 What Is Array in C#?: Arr4 (1) "Two"

The document discusses arrays in C#. It defines an array as a data structure that stores similar data types together as a single unit. Array elements can be accessed by their numeric index, which starts at 0. The document provides two examples of C# programs that initialize string arrays in different ways and an example of a program that passes an integer array as a parameter to a method. It also defines one-dimensional arrays as sections of memory containing data accessed through a pointer and multi-dimensional arrays as continuing the two-dimensional model.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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