System.RankException Class

public class RankException : SystemException

Base Types

Object
  Exception
    SystemException
      RankException

Assembly

mscorlib

Library

BCL

Summary

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

Example

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

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

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()
 

See Also

System Namespace

Members

RankException Constructors

RankException() Constructor
RankException(System.String) Constructor
RankException(System.String, System.Exception) Constructor


RankException() Constructor

public RankException();

Summary

Constructs and initializes a new instance of the RankException class.

Description

This constructor initializes the System.RankException.Message property of the new instance to a system-supplied message that describes the error, such as "The two arrays must have the same number of dimensions." This message takes into account the current system culture.

The System.RankException.InnerException property is initialized to null .

See Also

System.RankException Class, System Namespace

RankException(System.String) Constructor

public RankException(string message);

Summary

Constructs and initializes a new instance of the RankException class.

Parameters

message
A String that describes the error. The content of message is intended to be understood by humans. The caller of this constructor is required to ensure that this string has been localized for the current system culture.

Description

This constructor initializes the System.RankException.Message property of the new instance using message. If message is null , the System.RankException.Message property is initialized to the system-supplied message provided by the constructor that takes no arguments. The System.RankException.InnerException property is initialized to null .

See Also

System.RankException Class, System Namespace

RankException(System.String, System.Exception) Constructor

public RankException(string message, Exception innerException);

Summary

Constructs and initializes a new instance of the RankException class.

Parameters

message
A String that describes the error. The content of message is intended to be understood by humans. The caller of this constructor is required to ensure that this string has been localized for the current system culture.
innerException
An instance of Exception that is the cause of the current Exception. If innerException is non-null, then the current Exception was raised in a catch block handling innerException .

Description

This constructor initializes the System.RankException.Message property of the new instance using message, and the System.RankException.InnerException property using innerException. If message is null , the System.RankException.Message property is initialized to the system-supplied message provided by the constructor that takes no arguments.

[Note: For information on inner exceptions, see System.Exception.InnerException .]

See Also

System.RankException Class, System Namespace