自定义属性随版本而变化

时间:2018-08-02 06:56:12

标签: c#-4.0

我在Visual Studio 2017中为属性创建了一个自定义属性。我正在使用以下代码读取属性的值及其传递的值。

var propertyinforamtio = t.GetProperties().Where(prop => prop.GetCustomAttributes(typeof(FindsBy), true).Length != 0);
            try
            {
                for (int IndexOfProperty = 0; IndexOfProperty < propertyinforamtio.Count(); IndexOfProperty++)
                    propertyinforamtio.ElementAt(IndexOfProperty).SetValue(propertyinforamtio.ElementAt(IndexOfProperty).Name, propertyinforamtio.ElementAt(IndexOfProperty).CustomAttributes.First().ConstructorArguments.First().Value);
            }

这有效。

但是当我在vs 2013 Ultimate中调用同一程序时,我看到的是自定义属性不直接存在。它在基本财产下的存在。我的代码失败了吗?

任何人都可以在这里帮助我。enter image description here

enter image description here

0 个答案:

没有答案