此文章由人工翻译。 将光标移到文章的句子上,以查看原文。
|
译文
原文
|
Array 类
程序集: mscorlib(在 mscorlib.dll 中)
Array 类型公开以下成员。
名称 | 说明 | |
---|---|---|
IsFixedSize | ||
IsReadOnly | ||
IsSynchronized | ||
Length | ||
LongLength | ||
Rank | ||
SyncRoot |
名称 | 说明 | |
---|---|---|
AsReadOnly<T> | ||
BinarySearch(Array, Object) | ||
BinarySearch(Array, Object, IComparer) | ||
BinarySearch(Array, Int32, Int32, Object) | ||
BinarySearch(Array, Int32, Int32, Object, IComparer) | ||
BinarySearch<T>(T[], T) | ||
BinarySearch<T>(T[], T, IComparer<T>) | ||
BinarySearch<T>(T[], Int32, Int32, T) | ||
BinarySearch<T>(T[], Int32, Int32, T, IComparer<T>) | ||
Clear | ||
Clone | ||
ConstrainedCopy | ||
ConvertAll<TInput, TOutput> | ||
Copy(Array, Array, Int32) | ||
Copy(Array, Array, Int64) | ||
Copy(Array, Int32, Array, Int32, Int32) | ||
Copy(Array, Int64, Array, Int64, Int64) | ||
CopyTo(Array, Int32) | ||
CopyTo(Array, Int64) | ||
CreateInstance(Type, Int32) | ||
CreateInstance(Type, Int32[]) | ||
CreateInstance(Type, Int64[]) | ||
CreateInstance(Type, Int32, Int32) | ||
CreateInstance(Type, Int32[], Int32[]) | ||
CreateInstance(Type, Int32, Int32, Int32) | ||
Equals(Object) | ||
Exists<T> | ||
Finalize | ||
Find<T> | ||
FindAll<T> | ||
FindIndex<T>(T[], Predicate<T>) | ||
FindIndex<T>(T[], Int32, Predicate<T>) | ||
FindIndex<T>(T[], Int32, Int32, Predicate<T>) | ||
FindLast<T> | ||
FindLastIndex<T>(T[], Predicate<T>) | ||
FindLastIndex<T>(T[], Int32, Predicate<T>) | ||
FindLastIndex<T>(T[], Int32, Int32, Predicate<T>) | ||
ForEach<T> | ||
GetEnumerator | ||
GetHashCode | ||
GetLength | ||
GetLongLength | ||
GetLowerBound | ||
GetType | ||
GetUpperBound | ||
GetValue(Int32) | ||
GetValue(Int32[]) | ||
GetValue(Int64) | ||
GetValue(Int64[]) | ||
GetValue(Int32, Int32) | ||
GetValue(Int64, Int64) | ||
GetValue(Int32, Int32, Int32) | ||
GetValue(Int64, Int64, Int64) | ||
IndexOf(Array, Object) | ||
IndexOf(Array, Object, Int32) | ||
IndexOf(Array, Object, Int32, Int32) | ||
IndexOf<T>(T[], T) | ||
IndexOf<T>(T[], T, Int32) | ||
IndexOf<T>(T[], T, Int32, Int32) | ||
Initialize | ||
LastIndexOf(Array, Object) | ||
LastIndexOf(Array, Object, Int32) | ||
LastIndexOf(Array, Object, Int32, Int32) | ||
LastIndexOf<T>(T[], T) | ||
LastIndexOf<T>(T[], T, Int32) | ||
LastIndexOf<T>(T[], T, Int32, Int32) | ||
MemberwiseClone | ||
Resize<T> | ||
Reverse(Array) | ||
Reverse(Array, Int32, Int32) | ||
SetValue(Object, Int32) | ||
SetValue(Object, Int32[]) | ||
SetValue(Object, Int64) | ||
SetValue(Object, Int64[]) | ||
SetValue(Object, Int32, Int32) | ||
SetValue(Object, Int64, Int64) | ||
SetValue(Object, Int32, Int32, Int32) | ||
SetValue(Object, Int64, Int64, Int64) | ||
Sort(Array) | ||
Sort(Array, Array) | ||
Sort(Array, IComparer) | ||
Sort(Array, Array, IComparer) | ||
Sort(Array, Int32, Int32) | ||
Sort(Array, Array, Int32, Int32) | ||
Sort(Array, Int32, Int32, IComparer) | ||
Sort(Array, Array, Int32, Int32, IComparer) | ||
Sort<T>(T[]) | ||
Sort<T>(T[], IComparer<T>) | ||
Sort<T>(T[], Comparison<T>) | ||
Sort<T>(T[], Int32, Int32) | ||
Sort<T>(T[], Int32, Int32, IComparer<T>) | ||
Sort<TKey, TValue>(TKey[], TValue[]) | ||
Sort<TKey, TValue>(TKey[], TValue[], IComparer<TKey>) | ||
Sort<TKey, TValue>(TKey[], TValue[], Int32, Int32) | ||
Sort<TKey, TValue>(TKey[], TValue[], Int32, Int32, IComparer<TKey>) | ||
ToString | ||
TrueForAll<T> |
名称 | 说明 | |
---|---|---|
AsParallel | ||
AsQueryable | ||
Cast<TResult> | ||
OfType<TResult> |
名称 | 说明 | |
---|---|---|
ICollection.CopyTo | ||
ICollection.Count | ||
ICollection.IsSynchronized | ||
ICollection.SyncRoot | ||
IList.Add | ||
IList.Clear | ||
IList.Contains | ||
IList.IndexOf | ||
IList.Insert | ||
IList.IsFixedSize | ||
IList.IsReadOnly | ||
IList.Item | ||
IList.Remove | ||
IList.RemoveAt | ||
IStructuralComparable.CompareTo | ||
IStructuralEquatable.Equals | ||
IStructuralEquatable.GetHashCode |
重要事项 |
---|
public class SamplesArray { public static void Main() { // Creates and initializes a new integer array and a new Object array. int[] myIntArray = new int[5] { 1, 2, 3, 4, 5 }; Object[] myObjArray = new Object[5] { 26, 27, 28, 29, 30 }; // Prints the initial values of both arrays. Console.WriteLine( "Initially," ); Console.Write( "integer array:" ); PrintValues( myIntArray ); Console.Write( "Object array: " ); PrintValues( myObjArray ); // Copies the first two elements from the integer array to the Object array. System.Array.Copy( myIntArray, myObjArray, 2 ); // Prints the values of the modified arrays. Console.WriteLine( "\nAfter copying the first two elements of the integer array to the Object array," ); Console.Write( "integer array:" ); PrintValues( myIntArray ); Console.Write( "Object array: " ); PrintValues( myObjArray ); // Copies the last two elements from the Object array to the integer array. System.Array.Copy( myObjArray, myObjArray.GetUpperBound(0) - 1, myIntArray, myIntArray.GetUpperBound(0) - 1, 2 ); // Prints the values of the modified arrays. Console.WriteLine( "\nAfter copying the last two elements of the Object array to the integer array," ); Console.Write( "integer array:" ); PrintValues( myIntArray ); Console.Write( "Object array: " ); PrintValues( myObjArray ); } public static void PrintValues( Object[] myArr ) { foreach ( Object i in myArr ) { Console.Write( "\t{0}", i ); } Console.WriteLine(); } public static void PrintValues( int[] myArr ) { foreach ( int i in myArr ) { Console.Write( "\t{0}", i ); } Console.WriteLine(); } } /* This code produces the following output. Initially, integer array: 1 2 3 4 5 Object array: 26 27 28 29 30 After copying the first two elements of the integer array to the Object array, integer array: 1 2 3 4 5 Object array: 1 2 28 29 30 After copying the last two elements of the Object array to the integer array, integer array: 1 2 3 29 30 Object array: 1 2 28 29 30 */
public class SamplesArray2{ public static void Main() { // Creates and initializes a new three-dimensional Array of type Int32. Array myArr = Array.CreateInstance( typeof(Int32), 2, 3, 4 ); for ( int i = myArr.GetLowerBound(0); i <= myArr.GetUpperBound(0); i++ ) for ( int j = myArr.GetLowerBound(1); j <= myArr.GetUpperBound(1); j++ ) for ( int k = myArr.GetLowerBound(2); k <= myArr.GetUpperBound(2); k++ ) { myArr.SetValue( (i*100)+(j*10)+k, i, j, k ); } // Displays the properties of the Array. Console.WriteLine( "The Array has {0} dimension(s) and a total of {1} elements.", myArr.Rank, myArr.Length ); Console.WriteLine( "\tLength\tLower\tUpper" ); for ( int i = 0; i < myArr.Rank; i++ ) { Console.Write( "{0}:\t{1}", i, myArr.GetLength(i) ); Console.WriteLine( "\t{0}\t{1}", myArr.GetLowerBound(i), myArr.GetUpperBound(i) ); } // Displays the contents of the Array. Console.WriteLine( "The Array contains the following values:" ); PrintValues( myArr ); } public static void PrintValues( Array myArr ) { System.Collections.IEnumerator myEnumerator = myArr.GetEnumerator(); int i = 0; int cols = myArr.GetLength( myArr.Rank - 1 ); while ( myEnumerator.MoveNext() ) { if ( i < cols ) { i++; } else { Console.WriteLine(); i = 1; } Console.Write( "\t{0}", myEnumerator.Current ); } Console.WriteLine(); } } /* This code produces the following output. The Array has 3 dimension(s) and a total of 24 elements. Length Lower Upper 0: 2 0 1 1: 3 0 2 2: 4 0 3 The Array contains the following values: 0 1 2 3 10 11 12 13 20 21 22 23 100 101 102 103 110 111 112 113 120 121 122 123 */
Windows 7, Windows Vista SP1 或更高版本, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008(不支持服务器核心), Windows Server 2008 R2(支持 SP1 或更高版本的服务器核心), Windows Server 2003 SP2
.NET Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求。