using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Array_Ex_1
{
class Program
{
static void Main(string[] args)
{
//Declare
//Create
//Populate it
//Access items (elements)
//Step 1. Declaring an array variable
int[] x; //x is an array of integers
//Step 2. Define the size of the array
x = new int[10] { 2, -5, 3, 7, -9, 12, -33, 19, 15, -25 };
//or
//You can combine step 1 and 2
//int [] x = new int [10] { 2, -5, 3, 7, -9, 12, -33, 19, 15, -25 };
//or
//int [] x = { 2, -5, 3, 7, -9, 12, -33, 19, 15, -25 }
//Display the array x
for (int i = 0; i < x.Length; i++)
{
Console.WriteLine("Index: {0} Value: {1}", i, x[i]);
}
//Displaying Propery Length of x array
Console.WriteLine("\nArray x propery: {0}", x.Length);
Console.ReadKey();
}
}
}
No comments:
Post a Comment