Creation and testing of arrays whose lower limit is not 0:
Using system;
Using nunit. Framework;
[Testfixture]
Public class app
{
Static void main ()
{
App = new app ();
App. Run ();
}
[Test]
Public void run ()
{
Int [] lower = {3, 5}; // the lower threshold of one-dimensional start is 3, and the lower threshold of two-dimensional start is 5.
Int [] length = {2, 3}; // the length of one dimension is 2, and the length of two dimensions is 3.
// Create an array with a lower limit of not 0.
Decimal [,] dec = (decimal [,]) array. createinstance (typeof (decimal ),
Length, lower );
Assert. isnotnull (Dec, "DEC is null ");
// One-dimensional loop.
For (INT I = dec. getlowerbound (0); I <= dec. getupperbound (0); I ++)
{
// Two-dimensional loop
For (Int J = dec. getlowerbound (1); j <= dec. getupperbound (1); j ++)
{
// Assign a value.
Int [] val = new int [2] {I, j };
Dec. setvalue (decimal) (I * j), Val );
Console. writeline ("Dec [{0}, {1}] is: {2}", I, j, Dec [I, j]);
}
}
// Test
Assert. areequal (15 m, Dec [3, 5]);
Assert. areequal (28 m, Dec [4, 7]);
}
}