我正在尝试将这几行 C# 转换为 Vb 几个小时,但我无法使其工作。
Friend Shared Function GetErrorCorrectPolynomial(ByVal errorCorrectLength As Integer) As tPolynomial
Dim a As tPolynomial
a = New tPolynomial(New DataCache() With {1}, 0)
For i As Integer = 0 To errorCorrectLength - 1
a = a.Multiply(New tPolynomial(New DataCache() With { 1, tMath.GExp(i) }, 0))
Next i
Return a
End Function
我收到此错误 在对象初始化程序中初始化的字段或属性的名称必须以“。”开头
在这部分{1}
原始代码
internal static tPolynomial GetErrorCorrectPolynomial(int errorCorrectLength)
{
tPolynomial a = new tPolynomial(new DataCache() { 1 }, 0);
for (int i = 0; i < errorCorrectLength; i++)
{
a = a.Multiply(new tPolynomial(new DataCache() { 1, tMath.GExp(i) }, 0));
}
return a;
}
编辑添加 Datacache 类
Friend Class DataCache
Inherits List(Of Integer)
Public Sub New(ByVal capacity As Integer)
MyBase.New()
For i As Integer = 0 To capacity - 1
MyBase.Add(0)
Next i
End Sub
Public Sub New()
MyBase.New()
End Sub
End Class