Implementing Object Comparison(nuclex.org)
submitted by
Cygon(134) 2 years, 5 months ago
Comparison operators are often implemented poorly in .NET, in the sense that they contain duplicate code or perform certain checks, like a null reference test, multiple times. This article demonstrates a pattern that you can use to implement object comparison in a way that causes zero redundant code and achieves perfect efficiency (no comparison, not even a null check, is performed twice). It also provides a solution for comparison in inherited classes and integrates well with the == and != operators - all again without any redundant code and achieving optimal efficiency.
|category: Patterns
|Views: 10
tags:
comparison Patterns another
Everyones tags:
Your Tags: