[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
CSharpArray

(C#) array

A way to store a a large number of values and access them by index.

Example

//Setting the size of the array
const int size = 10;
//Declare the array
int[] myArray = new int[size];
//Initializing array
for(int i=0; i<size; ++i) myArray[i] = i;
//Showing array on screen way #1
for(int i=0; i<size; ++i) 
    Console.WriteLine("Array[" + i.ToString() + "]: " + myArray[i].ToString());
//Showing array on screen way #2
foreach (int i in myArray) 
    Console.WriteLine("Array[" + i.ToString() + "]: " + myArray[i].ToString());


An alternative to using a plain array is to use the ArrayList class, which can change size at run-time.

Array links

Code links



last edited (July 27, 2006) by bilderbikkel, Number of views: 1275, Current Rev: 3 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.