G
Gianluca
If you create an array using Array.CreateInstance() and use a lower bound >
0, you apparently get an array of the wrong type.
int[] lenghts = new int[] {1};
int[] lowerBounds = new int[] {1};
string[] ar = (string[])Array.CreateInstance(typeof(string), lengths,
lowerBounds);
Throws an InvalidCastException because "string[*]" cannot be casted to
"string[]".
int[] lenghts = new int[] {1};
int[] lowerBounds = new int[] {0};
string[] ar = (string[])Array.CreateInstance(typeof(string), lengths,
lowerBounds);
This works fine. The only difference in the lower bound.
int[] lenghts = new int[] {1,1};
int[] lowerBounds = new int[] {1,1};
string[,] ar = (string[,])Array.CreateInstance(typeof(string), lengths,
lowerBounds);
Even this work fine. The difference is the number of dimensions. So the
problem cannot be just the lower bound > 0 because in this case (and with
more dimensions too) it works well.
Everything works well in .NET 1.1. So it's apparently a bug introduced in
..NET 2.0.
Has anyone seen this before? And what is "string[*]"?
Regards,
Gianluca
0, you apparently get an array of the wrong type.
int[] lenghts = new int[] {1};
int[] lowerBounds = new int[] {1};
string[] ar = (string[])Array.CreateInstance(typeof(string), lengths,
lowerBounds);
Throws an InvalidCastException because "string[*]" cannot be casted to
"string[]".
int[] lenghts = new int[] {1};
int[] lowerBounds = new int[] {0};
string[] ar = (string[])Array.CreateInstance(typeof(string), lengths,
lowerBounds);
This works fine. The only difference in the lower bound.
int[] lenghts = new int[] {1,1};
int[] lowerBounds = new int[] {1,1};
string[,] ar = (string[,])Array.CreateInstance(typeof(string), lengths,
lowerBounds);
Even this work fine. The difference is the number of dimensions. So the
problem cannot be just the lower bound > 0 because in this case (and with
more dimensions too) it works well.
Everything works well in .NET 1.1. So it's apparently a bug introduced in
..NET 2.0.
Has anyone seen this before? And what is "string[*]"?
Regards,
Gianluca