Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在 c# 中定义属性,它接受像这样的参数“Text1.Attributes[“onfocus”]” 这里属性是 Text1 对象的属性接受参数
C# 不支持参数化属性。
相反,您需要使用带有这些参数的索引器创建一个类,然后创建一个返回该类实例的属性。
例如:
class AttributesCollection : ... { public Something this[string name] { ... } } class TextBox { public AttributesCollection Attributes { get; } }