比较两个类型ITWEET的阵列

发布于 2025-02-04 16:32:47 字数 429 浏览 2 评论 0原文

我想比较两个类型itweet的阵列,请注意,此类不是我的,并且似乎内部没有平等比较。

ITweet[] tweets = await GetLikes();
ITweet[] newTweets = await GetLikes();

if (!tweets.SequenceEqual(newTweets))
{
    // Notice that this won't work
}

newTweets.Except(tweets); // This neither

我该如何比较它们?我想使用,除非我确实需要那些不同的发生。正确的方法是什么?

更新:我注意到itweet实现iquabalable,但由于某种原因equals 均无效。

I'd like to compare two arrays of type ITweet notice that this class isn't mine, and seems it doesn't have Equality Comparer inside.

ITweet[] tweets = await GetLikes();
ITweet[] newTweets = await GetLikes();

if (!tweets.SequenceEqual(newTweets))
{
    // Notice that this won't work
}

newTweets.Except(tweets); // This neither

How could I compare them? I'd like to use Except since I do need those different ocurrences. What'd be the correct approach?

Update: I noticed ITWeet implements IEquatable but for some reason Equals don't work neither.

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

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

发布评论

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