我有以下一段代码。
class Program
{
static void Main(string[] args)
{
Enterprise.Initialize("Awesome Company");
// Assertion failed when constructor of 'Reg' class is disabled.
Debug.Assert(Reg.Root == @"Software\Awesome Company");
}
}
public static class Enterprise
{
// Static Properties.
public static string Company
{
get;
private set;
}
// Static Methods.
public static void Initialize(string company)
{
Company = company;
}
}
public class Reg
{
public static string Root = $@"Software\{Enterprise.Company}";
// ctor.
static Reg()
{
// Assertion failed when this constructor is …Run Code Online (Sandbox Code Playgroud) 我创建了一个由LabVIEW编译的.NET库,它有一个带有数字和被乘数的函数.此函数将返回一个数组,其中每个数字都与被乘数相乘.当在C#中调用该函数时,事实证明该函数采用非零索引数组(double[*])和a int作为参数并返回另一个非零索引数组.
我可以用C#的Array.CreateInstance()方法创建一个非零索引数组.但是我无法将此数组传递给函数,因为所需的数据类型是double[*].
从互联网上的研究来看,.NET似乎不支持非零索引数组类型.我试图找到一种方法来修改LabVIEW程序,以生成一个无法获得零索引数组的函数.
关于我如何解决这个问题的任何建议?
更新1
C#计划
const int Length = 5;
const int LowerBound = 1;
// Instanstiate a non-zero indexed array. The array is one-dimensional and
// has size specified by Length and lower bound specified by LowerBound.
Array numbers = Array.CreateInstance(typeof(double), new int[] { Length }, new int[] { LowerBound });
// Initialize the array.
for (int i = numbers.GetLowerBound(0); i <= numbers.GetUpperBound(0); i++)
{
numbers.SetValue(i, i);
}
var …Run Code Online (Sandbox Code Playgroud)