考虑以下:
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.ReturnValue)]
public class NotNullAttribute : Attribute
{
}
public class Class1
{
[return: NotNull]
public static string TestMethod([NotNull] string arg)
{
return arg + " + " + arg;
}
}
如何使用 System.Reflection 看到 NotNullAttribute 属性已应用于方法的返回值?如果不能,那么 [return: ] 语法背后的目的是什么?