-2

私はリストを持っています

 List<PossibleSolutionCapacitors> PossibleSolution = new List<PossibleSolutionCapacitors>(); 

ここにそのクラスがあります

 class PossibleSolutionCapacitors
    {
        public int CapacitorALocation { get; set; }
        public int CapacitorBLocation { get; set; }
        public int CapacitorCLocation { get; set; }    
    }

私は3つの整数を持っています

 int A;
 int B;
 int C;

A、B、C のいずれかの組み合わせが可能な解決策のリストに含まれているかどうかを確認する必要があります

すなわち、以下がリストにある場合 (true/false を示すブール値で十分です)

  1. A、B、C
  2. A、C、B
  3. B、A、C
  4. 等...

これは可能ですか?

ありがとうダモ

4

2 に答える 2

3

Saveのソリューションのバリエーション:

var fixedSet = new HashSet<int>(){A,B,C};
bool result = PossibleSolutions.Any(x => fixedSet.SetEquals(
    new[] { x.CapacitorALocation,x.CapacitorBLocation,x.CapacitorCLocation }));
于 2013-09-03T21:22:30.523 に答える