小编Pet*_*tas的帖子

具有不同返回类型的重载函数

我有两个具有相同名称的函数,主要区别在于不同的返回类型.我怎么能重载函数才能使用相同的名称,因为有时我需要point3d或point3f数组,以下函数名称给出相同的错误:

public static Point3d[] GetNGonCenters(this Mesh mesh)
{
    Point3d[] centers = new Point3d[mesh.Ngons.Count];

    for (int i = 0; i < mesh.Ngons.Count; i++)
        centers[i] = mesh.Ngons.GetNgonCenter(i);

    return centers;
}

public static Point3f[] GetNGonCenters(this Mesh mesh)
{
    Point3f[] centers = new Point3f[mesh.Ngons.Count];

    for (int i = 0; i < mesh.Ngons.Count; i++)
        centers[i] = (Point3f)mesh.Ngons.GetNgonCenter(i);

    return centers;
}
Run Code Online (Sandbox Code Playgroud)

c# overloading

2
推荐指数
1
解决办法
1130
查看次数

使用"List <int []>检查列表中的数组.包含(new int [] {..})",始终返回false

我试图检查由int [2]数组组成的列表是否包含某些元素.

总之,为什么这会产生错误?我该如何正确检查?

List < int[] > ngonPairs = new List<int[]> {new int[2] { 0, 1 }};

bool flag = ngonPairs.Contains(new int[2] { 0, 1 });
Run Code Online (Sandbox Code Playgroud)

标志总是错误的.

c# contains

1
推荐指数
1
解决办法
3421
查看次数

标签 统计

c# ×2

contains ×1

overloading ×1