이상한 어커런스가있는 배열의 번호를 원합니다.linq 쿼리 출력 -> System.Linq.Lookup`2 + 그룹화 [System.Int32, System.Int32]
이것은 내 코드입니다. 나는 그것이 작동하고 있다고 생각하지만 예상되는 숫자 2를 문자열로 출력 할 수 없다. 나는
System.Linq.Lookup`2+Grouping[System.Int32,System.Int32]
대신에 있습니다. 문제를 해결하는
int[] array = { 0, 0, 1, 1, 2 };
var result = array.GroupBy(a => a)
.Select(o => o)
.Where(o => (o.Count() % 2 == 1))
.FirstOrDefault();
Console.WriteLine(result.ToString());
당신은'FirstOrDefault'의 술어를 전달하여 더 좋은 수행 할 수 있습니다 2 == 1) .Key' –