I've found similar threads in the forum but they are all a little different from what I'm trying to do. So, here is the issue:
In Visual Basic, I've tried the code below and it's runs okay.
Public MatDim As Integer ' defined as global variable
Public Class CMatrix
Public n As Integer = MatDim
Public a (n, n) As Double
...
End Class
Public Sub Main()
...
MatDim = DimFile.ReadLine ()
Dim a As New CMatrix
...
End Sub
In C#, I've tried the same approach (below); didn't work out for me.
public static class GlobalVars {
public static int MatDim;
}
public class CMatrix {
public const int n = GlobalVars.MatDim;
public double [,] a = new double [n, n];
public double MatDet;
...
}
public ActualCodeToRun () {
...
MatDim = 10;
m = new CMatrix;
...
}
No comments:
Post a Comment