0
回到我的東西,看起來像下面這樣:CustomAttributes不被按預期
[CoolnessFactor]
interface IThing {}
class Tester
{
static void TestSomeInterfaceStuff<T>()
{
var attributes = from attribute
in typeof(T).GetCustomAttributes(typeof(T), true)
where attributes == typeof(CoolnessFactorAttribute)
select attribute;
//do some stuff here
}
}
,然後我會叫它像這樣:
TestSomeInterfaceStuff<IThing>();
然而,當我這樣做,它根本不返回任何屬性。
想法?