找出重载查找里的 bug

来自 反射
C# 14 / .NET 10 进阶 4分钟 找出 1处问题

找出增加第二个重载后方法解析失败的原因。

csharp
using System;
using System.Reflection;

Type type = typeof(Formatter);
MethodInfo format = type.GetMethod("Format")!;
Console.WriteLine(format.Invoke(new Formatter(), [12m]));

public sealed class Formatter
{
    public string Format(decimal value) => $"{value:F2}";
    public string Format(decimal value, string unit) => $"{value:F2} {unit}";
}
在试验场中打开
报告错误