当我发现我 在旅行 时调用GetHashCode()
了类的覆盖方法时,我感到很惊讶。但在其他情况下不会发生。为什么?Foo
foreach
IEnumerable<Foo>
真实代码的一些部分:
var allVolumeImagesInvolvedInMerge = volumeChainsToMerge
.SelectMany(x => x);
var allVolumeImagesNotInvolvedInMerge = allVolumeImagesWithinCell
.Except(allVolumeImagesInvolvedInMerge)
.Where(vi => volumeImagesNotAllowedToDelete.ContainsFast(vi) == false);
var volumeImagesCandidatesForDeletion = allVolumeImagesNotInvolvedInMerge
.Where(x => driverVolumeIds.Contains(x.DriverVolumeId));
var groupedVolumeImagesCandidatesForDeletion = volumeImagesCandidatesForDeletion
.GroupBy(vi => vi.DriverVolumeId);
// here GetHashCode is called
foreach (var group in groupedVolumeImagesCandidatesForDeletion)
{
...
}