GOA - System.Array

Array Class


Provides methods for manipulating arrays.This class is the base class for all arrays. This class cannot be inherited.

Definition

public sealed class Array: Object, ICloneable, ICollection, IEnumerable, IList

Members Table

MethodDescription
AddWhen implemented by a class, adds an item to the IList. (Inherited from IList)
BinarySearchOverloaded. Searches for a value in the sorted Array, using a binary search algorithm.
ClearOverloaded. (Inherited from IList)
CloneCreates a shallow copy of the Array.
ContainsWhen implemented by a class, determines whether the IList contains a specific value. (Inherited from IList)
CopyOverloaded. Copies a section of one Array to another Array.
CopyToCopies all the elements of the current one-dimensional Array to the specified one-dimensional Array at the specified index.
EqualsOverloaded. Compares two objects to determine if they are equal. (Inherited from Object)
FillOverloaded. Fills an Array with a specified Object.
GetEnumeratorReturns an IEnumerator for the Array.
GetHashCodeServes as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table. (Inherited from Object)
GetLengthGets the number of elements in the Array.
GetTypeGets the Type of the current instance. (Inherited from Object)
GetValueGets the value at the specified position in the one-dimensional Array.
IndexOfOverloaded. (Inherited from IList)
InsertWhen implemented by a class, inserts an item to the IList at the specified position. (Inherited from IList)
LastIndexOfOverloaded. Returns the index of the last occurrence of a value in an array or in a part of the Array.
ReferenceEqualsDetermines whether the specified Object instances are the same instance. (Inherited from Object)
RemoveWhen implemented by a class, removes the first occurrence of a specific object from the IList. (Inherited from IList)
RemoveAtWhen implemented by a class, removes the IList item at the specified index. (Inherited from IList)
ResizeOverloaded. Changes the size of an array to the specified new size.
ResizeArrayChanges the size of an array to the specified new size.
ReverseOverloaded. Reverses the order of the elements in a one-dimensional Array or in a part of the Array.
SetValueSets a value to the specified element in the one-dimensional Array.
SortOverloaded. Sorts the elements in the Array objects.
SwapElementsSwaps two elements base on the indexes of the Array.
System.Collections.IList.AddAlways throws an exception.
System.Collections.IList.ClearSets all elements in the Array to zero, to false, or to a null reference.
System.Collections.IList.ContainsDetermines whether an element is in the Array.
System.Collections.IList.IndexOfSearches for the specified object and returns the index of the first occurrence within the current instance.
System.Collections.IList.InsertAlways throws an exception.
System.Collections.IList.RemoveAlways throws an exception.
System.Collections.IList.RemoveAtAlways throws an exception.
System.Collections.IList.this[]Gets or sets the value to the Array at the specified index.
ToStringOverriden. Returns a String that represents the current Object.
this[]When implemented by a class, gets or sets an item to the IList. (Inherited from IList)
PropertyDescription
CountGets the number of elements contained by the ICollection. (Inherited from ICollection)
IsFixedSizeGets a value indicating whether the Array has a fixed size.
IsReadOnlyGets a value indicating whether the Array is read-only.
IsSynchronizedGets a value indicating whether access to the Array is synchronized.
LengthGets the total number of elements in the Array.
RankGets the rank of the Array.
SyncRootGets an object that can be used to synchronize access to the Array.
System.Collections.ICollection.CountThe number of the elements that contained in the ICollection.

Inheritance Hierarchy

Object
Array

Remarks

Multidimensional arrays are not supported.

Examples

// This sample shows how to implement the Array. It also shows some methods that use for the Array.

 

using System;

using System.Diagnostics;

 

public class SampleArray

{

     static void Main()

     {

          // Creates and initializes a new integer array and a new object array.

          int[] myIntArray = new int[5]{30,25,20,15,10};

          object[] myObjectArray = new object[7]{4,5,1,2,3,7,6};

 

          // Displays the integer and object arrays.

          Debug.WriteLine(" Before sorting");

          Debug.Write("\t Integer array: ");

          DisplayArray(myIntArray);

          Debug.Write("\n\t Object array: \t");

          DisplayArray(myObjectArray);

 

          // Uses the sorting method.

          Array.Sort(myIntArray);

          Array.Sort(myObjectArray);

 

          // Displays the integer and object arrays.

          Debug.Write("\n\n After sorting");

          Debug.Write("\n\t Integer array: ");

          DisplayArray(myIntArray);

          Debug.Write("\n\t Object array: \t");

          DisplayArray(myObjectArray);

 

          // Copies myIntArray to myObjectArray starting at third index.

          myIntArray.CopyTo(myObjectArray, 2);

 

          // Displays the integer and object arrays.

          Debug.Write("\n\n After copying");

          Debug.Write("\n\t Integer array: ");

          DisplayArray(myIntArray);

          Debug.Write("\n\t Object array: \t");

          DisplayArray(myObjectArray);

 

          // Reverses the integer array.

          Array.Reverse(myIntArray);

          Array.Reverse(myObjectArray);

 

          // Displays the integer and object arrays.

          Debug.Write("\n\n After reversing");

          Debug.Write("\n\t Integer array: ");

          DisplayArray(myIntArray);

          Debug.Write("\n\t Object array: \t");

          DisplayArray(myObjectArray);

     }

 

     static void DisplayArray( int[] myArray )

     {

          for(int i = 0; i < myArray.Length; i++)

          {

               Debug.Write(myArray[i] + "\t");

          }

     }

     static void DisplayArray( object[] myArray )

     {

          for(int i = 0; i < myArray.Length; i++)

          {

               Debug.Write(myArray[i] + "\t");

          }

     }

}

 

/*

The output of the sample.

 

Before sorting

     Integer array: 30 25 20 15 10

     Object array:  4 5 1 2 3 7 6

 

After sorting

     Integer array: 10 15 20 25 30

     Object array:  1 2 3 4 5 6 7

 

After copying

     Integer array: 10 15 20 25 30

     Object array:  1 2 10 15 20 25 30

 

After reversing

     Integer array: 30 25 20 15 10

     Object array:  30 25 20 15 10 2 1

 

*/

Class Information

NamespaceSystem
Flash Librarycorlib.scl
Flash Library Version2.0.0.2466
Silverlight LibrarySystem.Windows.Forms.dll



© 2003-2007 NETiKA Technologies. All rights reserved.