- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What does the interface IStructuralEquatable do in C#?
The IStructuralEquatable interface defines methods to support the comparison of objects for structural equality, which means that two objects are equal because they have equal values.
It includes the following two methods −
Sr.No | Method & Description |
---|---|
1 | Equals(Object, IEqualityComparer) The method determined whether an object is structurally equal to the current instance. |
2 | GetHashCode(IEqualityComparer) The methods a hash code for the current instance. |
Let us see an example in which I have created Tuple objects and worked with IstructuralEquatable interface:
Create Tuples −
var tupleOne = Tuple.Create(26.3, Double.NaN, 35.6); var tupleOne = Tuple.Create(26.3, Double.NaN, 35.6);
Now check the equality by calling IStructuralEquatable.Equals using default comparer.
IStructuralEquatable chk = tupleOne; Console.WriteLine(chk.Equals(tupleTwo, EqualityComparer<object>.Default));
Advertisements