我是C#的新手。我想知道是否有可能在一个代码中有许多返回。我的代码目前不能工作。如下所示:
public static int GeometryandControlPoints(int t, double rinn, double rout, int nx, int ny, int poly)
{
int nel, n, m, ncp, gdof;
nel = nx * ny;
n = nx + poly;
m = ny + poly;
ncp = n * m;
gdof = 2* ncp;
return (nel, n, m, ncp, gdof);
}
错误出现在return
行上,如下图所示。
发布于 2019-06-06 07:00:11
按照Filip的建议,您可以使用Tuple返回多个int
public static Tuple<int, int, int, int, int> GeometryandControlPoints(int t, double rinn, double rout, int nx, int ny, int poly)
{
int nel, n, m, ncp, gdof;
nel = nx * ny;
n = nx + poly;
m = ny + poly;
ncp = n * m;
gdof = 2 * ncp;
return new Tuple<int, int, int, int, int>(nel,n, m, ncp, gdof);
}
另一种方法是创建一个封装了5个int的自定义类并返回它。
https://stackoverflow.com/questions/56468696
复制相似问题