ObjPtr从VB6在C#中当量(功能)?当量、功能、ObjPtr

2023-09-06 14:42:20 作者:不美不萌不做作

是否有任何人知道,如果C#有ObjPtr从VB6等同或等效功能(见下文的详细信息)?这里有几个环节信息的ObjPtr devx ,的 thevbzone 。

Does any one know if C# has an equivalent of ObjPtr from VB6, or equivalent functionality (see more info below)? Here are a couple of links to info on ObjPtr devx , thevbzone.

基本上,我有我需要走通获得特定的节点,但唯一的(相关)信息的节点已经是名第三方树状......但节点名不必是唯一的。所以,我需要为我走通它的第一次,所以当我走通了一遍,我知道这是要获得一个独特的价值为每个节点。在老同学VB6的日子里,我会用ObjPtr。

Basically I have a third party treeview that I need to walk thru to get specific nodes but the only (relevant) info the nodes have is name ... but the node names don't need to be unique. So I need to get a unique value for each node as I walk thru it the first time so when I walk thru it again I know which is which. In the old school VB6 days I would use ObjPtr.

任何想法或建议?

FK

推荐答案

如果他们的对象,为什么不直接存储对象引用?这些都将是独一无二的。

If they're objects, why not just store the object references directly? These will be unique.

您可以使用 Object.ReferenceEquals(X,Y)来确定是否已经存储的参考是指你刚刚从树上获取相同的对象。

You can use Object.ReferenceEquals(x, y) to determine if a reference you have stored is referring to the same object you just retrieved from the tree.