Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将LINQ C转换为VB.NET_C#_Vb.net_Migration - Fatal编程技术网

C# 将LINQ C转换为VB.NET

C# 将LINQ C转换为VB.NET,c#,vb.net,migration,C#,Vb.net,Migration,我在对付这个怪物: public static IEnumerable<Warp> GetWarps(IEnumerable<Point> sourcePoints, IEnumerable<Point> destPoints, IEnumerable<Triangle> destTriangles) { // build lists of source and destination landmark points var sou

我在对付这个怪物:

public static IEnumerable<Warp> GetWarps(IEnumerable<Point> sourcePoints, IEnumerable<Point> destPoints, IEnumerable<Triangle> destTriangles)
{
    // build lists of source and destination landmark points
    var sourceList = sourcePoints.ToList();
    var destList = destPoints.ToList();

    // find all three triangle points in the list of destination landmark points
    var indices = from t in destTriangles
                  let p1 = destPoints.First(p => Math.Abs(p.X - t.P1.X) < 1 && Math.Abs(p.Y - t.P1.Y) < 1)
                  let p2 = destPoints.First(p => Math.Abs(p.X - t.P2.X) < 1 && Math.Abs(p.Y - t.P2.Y) < 1)
                  let p3 = destPoints.First(p => Math.Abs(p.X - t.P3.X) < 1 && Math.Abs(p.Y - t.P3.Y) < 1)
                  select new {
                      X1 = destList.IndexOf(p1),
                      X2 = destList.IndexOf(p2),
                      X3 = destList.IndexOf(p3)
                  };

    // return enumeration of warps from source to destination triangles
    return from x in indices
           select new Warp(
               new Triangle(sourceList[x.X1], sourceList[x.X2], sourceList[x.X3]),
               new Triangle(destList[x.X1], destList[x.X2], destList[x.X3]));
}
我已经尝试了很多,但是我没有处理语法和陷阱的经验

我自己的方法都失败了,我完全不知道我是否走上了正确的方向:

函数GetWarpsByVal sourcePoints作为IEnumerableOf Point,ByVal destPoints作为IEnumerableOf Point,ByVal destTriangles作为IEnumerableOf Triangle作为IEnumerableOf Warp Dim sourceList=sourcePoints.ToList Dim destList=destPoints.ToList 将p1调整为三角形 将p2调整为三角形 将p3调暗为三角形 尺寸索引=从三角形中的t开始 p1=destPoints.FirstFunctionp Math.Absp.X-t.p1.X<1,以及aso Math.Absp.Y-t.p1.Y<1 p2=destPoints.firstfunction p Math.Absp.X-t.p2.X<1和also Math.Absp.Y-t.p2.Y<1 p3=destPoints.firstfunction p Math.Absp.X-t.p3.X<1和also Math.Absp.Y-t.p3.Y<1选择 .X1=destList.IndexOfp1,键, .X2=destList.IndexOfp2,键, .X3=destList.IndexOfp3,键, 从索引中的x返回选择新扭曲新三角形sourceListx.X1、sourceListx.X2、sourceListx.X3、新三角形TestListX.X1、destListx.X2、destListx.X3 端函数 有人能告诉我怎么做才对吗

非常感谢

试试这个

公共共享函数GetWarpsByVal sourcePoints作为IEnumerableOf点,ByVal destPoints作为IEnumerableOf点,ByVal destTriangles作为IEnumerableOf三角形作为IEnumerableOf Warp Dim sourceList=sourcePoints.ToList Dim destList=destPoints.ToList Dim Index=From t In destPoints三角形中的p1=destPoints.FirstFunctionp Math.Absp.X-t.p1.X<1 AndAlso Math.Absp.Y-t.p1.Y<1让p2=destPoints.FirstFunctionp Math.Absp.X-t.p2.X<1让p3=destPoints.FirstFunctionp Math.Absp.X-t.p3.X<1 AndAlso Math.Absp.Y-t.p3.Y<1用{键选择新建 .X1=destList.IndexOfp1,键 .X2=destList.IndexOfp2,键 .X3=destList.IndexOfp3 } 从索引中的x返回选择新扭曲新三角形sourceListx.X1、sourceListx.X2、sourceListx.X3、新三角形TestListX.X1、destListx.X2、destListx.X3 端函数 我明白了!!:-

公共函数GetWarpsByVal sourcePoints作为IEnumerableOf点,ByVal destPoints作为IEnumerableOf点,ByVal destTriangles作为IEnumerableOf三角形作为IEnumerableOf Warp '生成源和目标地标点列表 Dim sourceList=sourcePoints.ToList Dim destList=destPoints.ToList '在目标地标点列表中查找所有三个三角形点 尺寸索引=从三角形中的t开始_ 设p1=destPoints.FirstFunctionp Math.Absp.X-t.p1.X<1 AndAlso Math.Absp.Y-t.p1.Y<1设p2=destPoints.FirstFunctionp Math.Absp.X-t.p2.X<1 AndAlso Math.Absp.Y-t.p2.Y<1设p3=destPoints.FirstFunctionp Math.Absp.X-t.p3.X<1 AndAlso Math.Absp.Y-t.p3.Y<1_ 使用{Key.X1=destList.IndexOfp1,Key.X2=destList.IndexOfp2,Key.X3=destList.IndexOfp3}选择新建 '返回从源三角形到目标三角形的扭曲枚举 指数中x的回报率_ 选择New WarpNew TrianglesourceListx.X1、sourceListx.X2、sourceListx.X3、New TriangledestListx.X1、destListx.X2、destListx.X3 端函数
谢谢,但由于各种错误,这不起作用。@t否则,您可以让函数保留在c中,只在vb中引用它。NET我该怎么做?因此,您需要一个解决方案,其中包含两个项目—一个是c,另一个是vb。VB项目是您的主要应用程序,C项目编译到类库中,您应该能够将对C项目的引用添加到VB项目中,然后很容易地从VB代码调用C代码。你可以尝试在网上搜索它。有一些教程介绍如何将c代码与vb.net混合/合并。不能在同一个项目/程序集中混合使用c和vb,但可以将第二个程序集/项目添加到不同语言的程序中,然后从第一个程序集/项目开始引用。我不建议这样做,任何人在一年或三年内看你的代码都会挠头