Arrays Articles

C# Simple, Rectangular, Mixed, and Jagged Arrays, Foreach Loops and Nested For Loops

Welcome to the 8th tutorial in the "C# for the Completely Uninitiated" series..   Simple Arrays Multidimensional (a.k.a. Rectangular) Arrays Jagged and Mixed Arrays Source code used in this tutorial:   namesarray.cs boundslength.cs deptstore.cs jobcandidates.cs simplenested.cs threed.cs Single Dimension Arrays An arrayis a collection of contiguous storage spaces in memory that are setaside to hold […]

Read more

C#: Array items in .NET

This sample code showsyou how to use arrays and access array items by using foreach loop. [C#]using System;namespace ArraySample{  class MyFirstArray {        static void Main(string[] args) {            int[] intUserID = new int[3];            intUserID[0] = 5;            intUserID[1] = 7;            intUserID[2] = 2;             Console.WriteLine(".:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.");                foreach (int i in intUserID) {                    Console.WriteLine("UserID: " + i.ToString());            } […]

Read more

Array class and IEnumerator in C#

  This article illustrates the usage of Array class and IEnumerator in C#. Array class Provides methods for creating,manipulating, searching and sorting arrays, thereby serving as the baseclass for all arrays in the common language runtime. The Array class implements ICloneable, IList, ICollection andIEnumerable Interfaces. Hence we can use GetEnumerator method forcreating Enumerators for our […]

Read more

Jagged Arrays In C# – What's That?

Overview I thank the editor for publishing my firstarticle ie 'Why C#' in csharphelp.com and also thankful to its readerfor their constructive suggestions and comments. This article discusses about the most talked datatype in the programming world – ARRAYS. C# offers two type of Arrays. 1. Rectangular Arrays2. Jagged Arrays . For those thaousand of […]

Read more

Jagged Array Example

Here is an example of how a Jagged Array works. The code I have included here also contains the decleration and it's operation. using System;public class MyArrayc2{ public static void Main() { int [][]arr=new int[4][]; arr[0]=new int[3]; arr[1]=new int[2]; arr[2]=new int[5]; arr[3]=new int[4]; Console.WriteLine("Enter the numbers for Jagged Array"); for(int i=0 ; i < arr.Length […]

Read more

C# Arrays

Open your favorite text editor and type the following C# source code: using System; public class ArrayMembers{ public static void Main(string[] args) { //Skip 1 line Console.WriteLine("\n"); //Iterate through the items of array args using foreach foreach(string s in args) { Console.WriteLine(s); } //Skip 2 lines Console.WriteLine("\n\n"); //Declare array strNames string[] strNames = {"Joe","Mary","Bill","Fred"}; //Iterate […]

Read more