使用反射时出现以下问题。C#反射问题
下面的语句评估为假:
object[] attributes = someType.GetCustomAttributes(true);
if (attributes[0] is NUnit.Framework.TestFixtureAttribute)
return true;
但是这个计算结果为真:
object[] attributes = someType.GetCustomAttributes(true);
if (attributes[0].ToString() == "NUnit.Framework.TestFixtureAttribute")
return true;
任何想法,为什么?
我同意全心全意。 – Will 2009-09-11 14:15:01
typeof运算(NUnit.Framework.TestFixtureAttribute).Assembly产生 'NUnit.Framework.TestFixtureAttribute' 存在于两个 'nunit.framework.dll中' 和 'nunit.framework.dll中' 所以我假定的类型有2个版本'nunit.framework.dll'在我的系统上。谢谢! – jamesaharvey 2009-09-11 14:38:59