For example =>
Array myArray = Array.CreateInstance(typeof(int), new[] { 7 }, new[] { 1 });
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am trying to create an single diminsion array that starts from 1 and ends at 7.
I tried this:
Int32[] lowerBounds = {1};
Int32[] lengths = {7};
Int32[] Julia = (Int32[])
Array.CreateInstance(typeof(Int32), lengths, lowerBounds);
But it generated a run-time error:
System.InvalidCastException: 'Unable to cast object of type 'System.Int32[*]' to type 'System.Int32[]'.'
Any suggestions? Thnak you.
For example =>
Array myArray = Array.CreateInstance(typeof(int), new[] { 7 }, new[] { 1 });