For this code:
class Program
{
static void Main()
{
Console.WriteLine(new MyStruct().ToString());
}
struct MyStruct { }
}
the C# compiler generates constrained callvirt
IL code.
This article says:
For example, if a value type V overrides the Object.ToString() method, a call V.ToString() instruction is emitted; if it does not, a box instruction and a callvirt Object.ToString() instruction are emitted. A versioning problem can arise <...> if an override is later added.
So, my question is: why would it be a problem in this case if the compiler will generate a box
code, not a constrained call?