Thursday, June 26, 2014

Variable sized arrays in C#

Well, yes, there are a lot of differenes between VB and C#. For example, a variable must be defined inside a class in C#.


But like I showed you in the previous post, you could use a static variable instead of a const:



public static class GlobalVars
{
public static int MatDim = 10;
}

public class CMatrix
{
public static int n = GlobalVars.MatDim;
public double[,] a = new double[n,n];
public double MatDet;
}

public SomeMethod()
{
CMatrix m = new CMatrix();
}


No comments:

Post a Comment