Best algorithm for synchronizing two IList in C# 2.0

前端 未结 6 1057
忘了有多久
忘了有多久 2020-12-10 05:12

Imagine the following type:

public struct Account
{
    public int Id;
    public double Amount;
}

What is the best algorithm to synchroniz

6条回答
  •  旧时难觅i
    2020-12-10 05:28

    For a start I'd get rid of the mutable struct. Mutable value types are a fundamentally bad thing. (As are public fields, IMO.)

    It's probably worth building a Dictionary so you can easily compare the contents of the two lists. Once you've got that easy way of checking for presence/absence, the rest should be straightforward.

    To be honest though, it sounds like you basically want L2 to be a complete copy of L1... clear L2 and just call AddRange? Or is the point that you also want to take other actions while you're changing L2?

提交回复
热议问题