-
Consider this example: using System;
ReadOnlyMemory<char> memory = new Char[] { 'a' };
Console.WriteLine("a".Equals(memory));
Console.WriteLine(Extensions.Equals("a", memory));
static class Extensions{
internal static bool Equals(this string value, ReadOnlyMemory<char> memory) => true;
} This produces "False, True". Why? Because the C# compiler binds the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Extensions aren't overloads, they're only considered if there are no instance members that match, even if they require type coercion. |
Beta Was this translation helpful? Give feedback.
-
See: 11.7.8.3 Extension method invocations
|
Beta Was this translation helpful? Give feedback.
Extensions aren't overloads, they're only considered if there are no instance members that match, even if they require type coercion.