对象验证(匹配类似对象)

时间:2017-01-26 09:27:35

标签: c# .net validation

我正在尝试将对象列表与Object进行比较,并选择最适合描述的对象或选择与用作验证的Object最相似的对象。让我说我有类似的东西:

 public class Person
{
    public string FNqme { get; set; }
    public string LName { get; set; }
    public string Job { get; set; }
    public string Car { get; set; }
}

数据如下所示:

       string[] person1 = System.IO.File.ReadAllLines(@"../../../person1.txt");  
    string[] person2 = System.IO.File.ReadAllLines(@"../../../person2.txt");
    string[] person3 = System.IO.File.ReadAllLines(@"../../../person3.txt");  
    string[] person4 = System.IO.File.ReadAllLines(@"../../../person4.txt");

和用于验证的人:

string[] validator=System.IO.File.ReadAllLines@"../../../personUsedForValidation.txt");

如何选择最接近相似性或与验证器对象最匹配的对象?

for instance Person1 FName = Foo, LName = Baa, Job = waiter, Car = Toyota
         Person2 FName = Nanny, LName = Benny, Job = cashier, Car = Nissan
         Person3 FName = Fiona, LName = Byron, Job = Nurse, Car = Ford

Validator FName = Nanny,LName = King,Job = cashier,Car = Tesler。

我希望能够从所有对象中选择人2,因为它似乎最接近验证器字符串。

请原谅我糟糕的英语。

0 个答案:

没有答案