linq in List< list< string>>任何功能都不给出正确的响应

发布于 2025-02-03 12:52:10 字数 1556 浏览 3 评论 0原文

失去理智,尝试使用更简单的东西,并做任何工作的功能。 我意识到我不需要将x,y转换为字符串,但这也不适合点。 函数“独特”不是一个选择,我会从更大的类中过滤这些坐标。此功能是一个简单的检查,即可避免使用真正复杂的LINQ功能。

        public static List<PXML_DocumentOrderProductSlabOutline> FilterMountpart21(List<PXML_DocumentOrderProductSlabOutline> Mountpart21Lijst)
    {
        List<PXML_DocumentOrderProductSlabOutline> Gefilterd = new List<PXML_DocumentOrderProductSlabOutline>();
        List<List<string>> GefilterdeSparingen = new List<List<string>>();

        for (int x = 0; x < Mountpart21Lijst.Count; x++)
        {
            var ShapeMountpart21Lijst = Mountpart21Lijst[x].Shape.First().SVertex;
            List<string> LijstVertex = new List<string>();
            foreach (var xyz in ShapeMountpart21Lijst)
            {
                string Punt = Convert.ToInt32(xyz.X) + ";" + Convert.ToInt32(xyz.Y);
                LijstVertex.Add(Punt);
            }

             //This fails
            if(!GefilterdeSparingen.Any(abc => abc == LijstVertex))
             //  

            {
                GefilterdeSparingen.Add(LijstVertex);
                Gefilterd.Add(Mountpart21Lijst[x]);
                System.Windows.MessageBox.Show(ResultaatFilterMountpart21(LijstVertex, GefilterdeSparingen));
            }
        }
        return Gefilterd;
    }

Losing my mind, tried it with something more simple and the function ANY does work ofcourse.
I realise I don't need to convert X,Y to strings, but it didn't work either with points.
Function 'Distinct' isn't an option, I filter those coordinates from a much larger class. This function is a simple check to not add doubles, to avoid a really complex LINQ function.

Search this item in the list, if it contains it, don't add it, if it doesn't contain it, add the item

        public static List<PXML_DocumentOrderProductSlabOutline> FilterMountpart21(List<PXML_DocumentOrderProductSlabOutline> Mountpart21Lijst)
    {
        List<PXML_DocumentOrderProductSlabOutline> Gefilterd = new List<PXML_DocumentOrderProductSlabOutline>();
        List<List<string>> GefilterdeSparingen = new List<List<string>>();

        for (int x = 0; x < Mountpart21Lijst.Count; x++)
        {
            var ShapeMountpart21Lijst = Mountpart21Lijst[x].Shape.First().SVertex;
            List<string> LijstVertex = new List<string>();
            foreach (var xyz in ShapeMountpart21Lijst)
            {
                string Punt = Convert.ToInt32(xyz.X) + ";" + Convert.ToInt32(xyz.Y);
                LijstVertex.Add(Punt);
            }

             //This fails
            if(!GefilterdeSparingen.Any(abc => abc == LijstVertex))
             //  

            {
                GefilterdeSparingen.Add(LijstVertex);
                Gefilterd.Add(Mountpart21Lijst[x]);
                System.Windows.MessageBox.Show(ResultaatFilterMountpart21(LijstVertex, GefilterdeSparingen));
            }
        }
        return Gefilterd;
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文