检查列表中是否存在guid [英] checking if guid is present in a list

查看:82
本文介绍了检查列表中是否存在guid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检查所选项目的guid是否出现在guid列表中?





[从OP解决方案帖子中添加]



i有一个带有几个标签的扩展器和这些标签有类似的项目。当你将这些项目从选项卡拖放到画布时,每个都会创建一个guid,这些guid会被保存到guid列表中。每个标签都有自己的列表。例如,我从选项卡1拖放对象和对象,如果项目的guid从第二个选项卡guid保存到选项卡2列表n中,则该项目的guid将保存到tab1列表中。我现在需要做的是当我在画布上选择一个项目时我需要一个窗口来显示它来自的标签名称

how do i check if the guid for the selected item is present in a list of guids?


[Added from OP "solution" post]

i have an expander with several tabs amd those tabs have similar items. when u drag and drop these items from the tab to a canvas each creates a guid and these guids gets saved into guid lists. each tab has a list for itself. example i drag n drop and object from tab 1 the guid for the item gets saved into the tab1 list n if its from the second tab guid gets saved into tab 2 list n so on. what i need to do now is when i select an item on the canvas i need a window to show the name of the tab it came from

推荐答案

有一个包含适用于任何类的方法:列表< T> .Contains [ ^ ]

由于Guid是一种Value类型,它可以使用默认的比较器。

There is a Contains method which works with any class:List<T>.Contains[^]
Since Guid is a Value type, it will work with the default comparer.
if (my list.Contains(guidToLookFor))
   {
   ...


这篇关于检查列表中是否存在guid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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