小编Z0R*_*RrO的帖子

如果散列中有一个或多个字段,则使用 HashSet 和 Contains 返回 TRUE

我想知道是否可以使用 HashSet 并使方法Contains返回 true 如果字段之一在给定对象的哈希中。

这是我想要的一个例子

static void Main(string[] args)
{
    HashSet<Product> hash = new HashSet<Product>();

    // Since the Id is the same, both products are considered to be the same even if the URI is not the same
    // The opposite is also true.  If the URI is the same, both products are considered to be the same even if the Id is not the same
    Product product1 = new Product("123", "www.test.com/123.html");
    Product product2 = new Product("123", …
Run Code Online (Sandbox Code Playgroud)

c# hashset

1
推荐指数
1
解决办法
8227
查看次数

标签 统计

c# ×1

hashset ×1