Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 算法比较2个列表,找到错误最少的方法_C#_Algorithm - Fatal编程技术网

C# 算法比较2个列表,找到错误最少的方法

C# 算法比较2个列表,找到错误最少的方法,c#,algorithm,C#,Algorithm,我在计算两个列表之间的差异时遇到了一些问题 第一个列表是预期的列表,这意味着,如果一切按计划进行,它应该是这样的 第二个列表是它实际运行情况的列表 我需要将这些与列表进行比较,并找出检查点是否缺失,或者是否存在错误注释,这意味着已经记录了一个不应该记录的检查点。检查点的顺序很重要,它必须与预期的顺序相同 我的问题是如何比较这两个列表,并找出最少的错误,然后标记这些错误 目前我已经上了3节课 预期类别: public class IdealRouteCheckpoint : ICheckpoint

我在计算两个列表之间的差异时遇到了一些问题

第一个列表是预期的列表,这意味着,如果一切按计划进行,它应该是这样的

第二个列表是它实际运行情况的列表

我需要将这些与列表进行比较,并找出检查点是否缺失,或者是否存在错误注释,这意味着已经记录了一个不应该记录的检查点。检查点的顺序很重要,它必须与预期的顺序相同

我的问题是如何比较这两个列表,并找出最少的错误,然后标记这些错误

目前我已经上了3节课

预期类别:

public class IdealRouteCheckpoint : ICheckpoint
{
    public IdealRouteCheckpoint(string checkpointValue, int minTime = 0, int maxTime = 0, bool defective = false, bool optional = false)
    {
        CheckpointValue = checkpointValue;
        Defective = defective;
        Optional = optional;
        MinTime = minTime;
        MaxTime = maxTime;
    }

    public string CheckpointValue { get; set; }

    //Used for when a Checkpoint this missing for when it placed wrong
    public bool Defective { get; set; } 
    //Used for when you do somehitng and know that people risk taking it
    public bool Optional { get; set; }

    //Used for OTK and HTK
    public int MinTime { get; set; }
    public int MaxTime { get; set; }
}
类的检查点从如何实际运行

public class NotedCheckPoint : ICheckpoint
{
    public NotedCheckPoint(string checkpointValue)
    {
        CheckpointValue = checkpointValue;
    }

    public string CheckpointValue { get; set; }


}
然后我考虑制作第三个类,应该有结果和错误标记,这样我最终可以将结果打印到PDF。那个班看起来像这样

public class ResultCheckpoint : ICheckpoint
{
    public ResultCheckpoint(string checkpointValue, bool missing = false, bool errorNote = false, int early = 0, int late = 0)
    {
        CheckpointValue = checkpointValue;
        Missing = missing;
        ErrorNote = errorNote;
        Early = early;
        Late = late;
    }

    public string CheckpointValue { get; set; }

    //MK when a checkpoint is missing on the controlCard
    public bool Missing { get; set; }
    //FN when there is a checkpoint too much on the controlCard
    public bool ErrorNote { get; set; }

    //When teams are too early to a HTK or OTK
    public int Early { get; set; }
    //When teams are too late to a HTK or OTK
    public int Late { get; set; }
}
我已经描述了我想要实现的目标,但我想我需要解释一些事情

左列是预期的单元格,其中没有任何内容用于为错误注释留出空间

结果列是实际记录的内容。没有任何东西的单元格将为丢失的检查点腾出空间

每个错误注释和缺少的检查点都要花费25分

最后一件事是有时间,但我认为我可以处理这一部分,当我找到了解决我的问题的办法


您能否按两个列表中必须相同的一个属性对它们进行排序,然后使用哈希(键值字典…其中键是您选择的此属性,值是实际对象)。然后,您将根据keyI compare比较这些字典值,如果这是您的意思,那么我的意思是准备预期和实际的键值对。示例[A,expectedObj1],[B,expectedObject2],[A,actualObj1],[C,actualObj2]。例如,这里缺少B。。我给你的是一个想法,不是一个解决方案