如何设置两个嵌套列表类的属性? [英] How to set property of two nested list class?

查看:87
本文介绍了如何设置两个嵌套列表类的属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

其实我面临一个问题,我想设置一个具有相同类型的另一个对象的相同属性的对象的属性。

Actually I'm facing one issue that I would like to set the propert of a object with same property of another object of same type.

我做了如下。它工作正常,但我想避免很多循环。在下面的代码中,我需要从我作为参数发送的另一个对象中设置所选点。请帮帮我。

I did as below. It is working fine but I would like to avoid many loops. In the below code, I need to set the selected point from another object that I'm sending as parameter. Please help me.

谢谢和问候,

Hari

点击"建议作为答案"如果这篇文章解决了你的问题或"投票有帮助"如果一篇文章对你有用,快乐编程! Hari

click "Proposed As Answer by" if this post solves your problem or "Vote As Helpful" if a post has been useful to you Happy Programming! Hari

推荐答案

如果除了任意数据点之外的2个点之间没有相关性,那么除非你从根本上改变你的设计嵌套循环是唯一的解决方案。目前还不清楚是什么会触发这种同步,但看起来你可能在
中有一些选项来实现这一点,所以枚举几乎是唯一的选择。如果mainGraphicData和ListGraph之间存在某种关系,那么您可以在对象之间存储引用,然后跳过查找部分,否则枚举是
不可避免。

If there is no correlation between the 2 points other than an arbitrary data point then unless you radically change your design nested loops is the only solution. It is unclear what would trigger this sync but it looks like maybe you have some option in your UI to do this so enumeration is pretty much the only option. If there is some sort of relationship between the mainGraphicData and ListGraph then you could store a reference between the objects and then skip the find part but otherwise enumeration is inevitable.

最多你可以做的就是清理LINQ背后的枚举。它仍然会发生,只是不是你这样做。我可以看到你将前2个foreach折叠成LINQ选择。然后我可以看到使用join子句将它与ListGraph
数据结合起来。从那里你可以创建一个连接主数据点和列表数据点的anony类型。最后,你可以运行一个变换(可能是一个foreach)来将linegraph上的点设置为maingraph。这不会比你可能的速度快,只需
少的代码。

The most you can probably do is clean up the enumeration behind LINQ. It's still going to happen, just not you doing it. I could see you collapse the first 2 foreach into a LINQ select. Then I could see the use of a join clause to combine it with the ListGraph data. From there you could create an anony type that connects the main and list data points. Finally you can run a transform (probably a foreach) to set the point on the linegraph to the maingraph. This won't be any faster than what you have probably, just less code.


这篇关于如何设置两个嵌套列表类的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆