Same method signature confusion

倾然丶 夕夏残阳落幕 提交于 2021-02-08 07:26:07

问题


Assuming C# 8.0 and reference type nullability, why are these signatures considered equal:

void Test<T>(IEnumerable<T> enumerable) where T : class
void Test<T>(IEnumerable<T> enumerable) where T : struct

but these are not?

void Test<T>(IEnumerable<T?> enumerable) where T : class
void Test<T>(IEnumerable<T?> enumerable) where T : struct

The only thing different is the nullability of enumerable elements.

来源:https://stackoverflow.com/questions/60115233/same-method-signature-confusion

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!