Steven Giesel 1/11/2022

Enum.Equals - Performance analysis

Read Original

This technical article benchmarks four methods for comparing enum values in C#: Object.Equals, Enum.Equals, instance.Equals, and the comparison operator (==). Using BenchmarkDotNet, it demonstrates that the == operator is dramatically faster (by a factor of ~100) due to the boxing overhead incurred by the Equals methods. The post explains the underlying reasons, focusing on boxing/unboxing and the internal implementation of object.Equals.

Enum.Equals - Performance analysis

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser

Top of the Week

No top articles yet