public class RankException : SystemException
Object
Exception
SystemException
RankException
mscorlib
BCL
Represents the error that occurs when an array with an incorrect number of dimensions is passed to a method.
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()
System Namespace
RankException Constructors
RankException() Constructor
RankException(System.String) Constructor
RankException(System.String, System.Exception) Constructor
public RankException();
Constructs and initializes a new instance of the RankException class.
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
.
System.RankException Class, System Namespace
public RankException(string message);
Constructs and initializes a new instance of the RankException class.
- 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.
This constructor initializes the System.RankException.Message property of the new instance using message. If message isnull
, 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 tonull
.
System.RankException Class, System Namespace
public RankException(string message, Exception innerException);
Constructs and initializes a new instance of the RankException class.
- 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 .
This constructor initializes the System.RankException.Message property of the new instance using message, and the System.RankException.InnerException property using innerException. If message isnull
, 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 .]
System.RankException Class, System Namespace