方法返回不同类型的值
public struct individuals{
public double[] fitness;
public double[,] chrom;
}
class Program
{
static double[] SUM(double[] a,double[,] b,int c,int d ,out double[,] e)
{
e = new double[c, d];
for (int i = 0; i < c; i++)
for(int j=0;j< d;j++)
{
e[i, j] = b[i, j];
}
return a ;
}
static void Main(string[] args)
{
individuals L = new individuals();
L.fitness=new double[6];
for (int i = 0; i < 6; i++)
{ L.fitness[i] = 0.1 * i;
}
L.chrom = new double[,] { { 1, 2, 3 }, { 1, 2, 3 }, { 1, 2, 3 }, { 1, 2, 3 }, { 1, 2, 3 }, { 1, 2, 3 } };
SUM(L.fitness,L.chrom,6,3,out double[,] e);
}
}
}
我要返回结构individuals
他的内容有一个一维数组(1行6列)fitness和一个二维数组(6行3列)chrom,
我想写一个方法直接返回结构体individuals或者同时返回fitness和chrom