我正在尝试解决如何从类中获取所需属性的问题。我可以使用像GetPropertiesForSerialization这样的函数,但我想使用Attributes。private string picture = "my.jpg"; public string Name= "myName";现在我想从其他类中获取属性var c = new C(); Console.Wri
TestAttribute MyAttribute = (TestAttribute)System.Attribute.GetCustomAttribute(typeof(T), typeof(TestAttribute));}
但这会导致下面的错误;Attribute似乎只有Equals和ReferenceEquals两个方法。Error CS0117: 'Attribute' does not contain a definition for 'GetCustomAttribute