![]() If this method call returns true, the method is called again and passed the Item2 values of the two Tuple objects. The IStructuralEquatable.Equals(Object, IEqualit圜omparer) method first passes the Item1 values of the Tuple objects to be compared to the IEqualit圜omparer.Equals implementation. The IEqualit圜omparer.Equals implementation is called only if other is not null, and if it can be successfully cast (in C#) or converted (in Visual Basic) to a Tuple object whose components are of the same types as the current instance. It can be used only when the Tuple instance is cast to an IStructuralEquatable interface. This member is an explicit interface member implementation. ' The example displays the following output: Compare first tuple with remaining two tuples.Ĭonsole.WriteLine(" = ", rate1.ToString())Įq.Equals(rate2, New RateComparer(Of String, Double, Double, Double, Double, Double, Double)()))Įq.Equals(rate3, New RateComparer(Of String, Double, Double, Double, Double, Double, Double)()))Įq.Equals(rate4, New RateComparer(Of String, Double, Double, Double, Double, Double, Double)())) Var rate3 = Tuple.Create("Unknown City", -.013934. Var rate2 = Tuple.Create("Unknown City", -.013934. Return Math.Round(((double) obj) * 1000).GetHashCode() Public new bool Equals(object x, object y) Public class RateComparer : IEqualit圜omparer ![]() The example uses this IEqualit圜omparer implementation to determine whether four Tuple objects that contain data on the rate of population change between 19 are equal. Otherwise, it simply calls the x parameter's Equals method. If the values that are passed to its IStructuralEquatable.Equals method are of type Single or Double, the method tests for equality by using only up to three fractional digits. The following example defines a RateComparer class that performs a custom test for equality. ![]() ![]() ![]() Equals(Object, IEqualit圜omparer) Examples ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |