Mono Class Library: System Namespace

System.RankException Class

Represents the error that occurs when an array with an incorrect number of dimensions is passed to a method. [Edit]

See Also: RankException Members

System.Object
     System.Exception
          System.SystemException
               System.RankException

[System.Runtime.InteropServices.ComVisible(true)]
public class RankException : SystemException

Thread Safety

All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.

Remarks

Documentation for this section has not yet been entered. [Edit]

Example

The following example demonstrates an error that causes a RankException exception.

C# Example
using System;
public class RankExample {
   public static void Main() {
      int[] oneDAry = new int[5];
      int[,] twoDAry = new int[2,3];
      for (int i = 0; i < 2; i++ ) {
         oneDAry.SetValue( i, i );
      }
      try {
         Array.Copy( oneDAry, twoDAry, 2);
      }
      catch ( RankException e ) {
         Console.WriteLine( "Error caught: {0}", e );
      }
   }
}
   

The output is

Example
Error caught: System.RankException: The specified arrays must have the same number of dimensions.
   at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length)
   at System.Array.Copy(Array sourceArray, Array destinationArray, Int32 length)
   at RankExample.Main()
 

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0