CSharp · Console
using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
public class Human
{
public string FirstName{ get; set; }
public string LastName{ get; set; }
public List<Clothing> clothings { get; set; }
}
public class Clothing
{
public string ClothingID{ get; set; }
public string ColorTop{ get; set; }
public string ColorPants{ get; set; }
}
public class CurrentClothes
{
public string ColorTop{ get; set; }
public string ColorPants{ get; set; }
}
public static void Main()
{
Human h = new Human();
h.clothings = new List<Clothing>();
h.clothings.Add(new Clothing() { ColorTop = "Green", ColorPants = "A" });
h.clothings.Add(new Clothing() { ColorTop = "Red", ColorPants = "B" });
h.clothings.Add(new Clothing() { ColorTop = "Blue", ColorPants = "C" });
h.clothings.Add(new Clothing() { ColorTop = "Brown", ColorPants = "D" });
h.clothings.Add(new Clothing() { ColorTop = "Turqoise", ColorPants = "T" });
List<CurrentClothes> currentClothes = new List<CurrentClothes>();
currentClothes.Add(new CurrentClothes() { ColorTop = "Green", ColorPants = "A" });
currentClothes.Add(new CurrentClothes() { ColorTop = "Turqoise", ColorPants = "T" });
currentClothes.Add(new CurrentClothes() { ColorTop = "Red", ColorPants = "X" });
var sameClothings = h.clothings.Where(x => currentClothes.Any(s => s.ColorPants == x.ColorPants && s.ColorTop == x.ColorTop)).ToList();
foreach(var item in sameClothings) {
Console.WriteLine($"{item.ColorTop}-{item.ColorPants}");
}
}
}