我正在尝试将vb6代码转换为c#代码.我的vb6源代码包含各种类型的数组,经过Vs2005工具转换后,这些数组已成为基于0的数组,但我需要重新转换为非基于0的数组.例如,我尝试使用Array.CreateInstance显式转换为T []用于通用用法:
public void ResizeArrayBaseN<T>(ref T[] original, int firstLower, int firstCount)
{
try
{
int[] myBoundsArray = new int[1] {firstLower };
int[] myLengthsArray = new int[1] {firstCount - firstLower + 1 };
original = (T[])Array.CreateInstance(typeof(T), myLengthsArray, myBoundsArray);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Run Code Online (Sandbox Code Playgroud)
但我正在捕捉从T [*]到T []错误的演员表.有谁可以帮助我吗 ?提前致谢