csharp System.ComponentModel.DefaultPropertyAttribute类(方法)实例源码

下面列出了csharp System.ComponentModel.DefaultPropertyAttribute 类(方法)源码代码实例,从而了解它的用法。

作者:.NET开发    项目:System.ComponentMode   
[DefaultProperty("MyProperty")]
 public class MyControl : Control {
 
    public int MyProperty {
       get {
          // Insert code here.
          return 0;
       }
       set {
          // Insert code here.
       }
    }
 
    // Insert any additional code.
 }

作者:.NET开发    项目:System.ComponentMode   
public static int Main() {
    // Creates a new control.
    MyControl myNewControl = new MyControl();
 
    // Gets the attributes for the collection.
    AttributeCollection attributes = TypeDescriptor.GetAttributes(myNewControl);
 
    /* Prints the name of the default property by retrieving the 
     * DefaultPropertyAttribute from the AttributeCollection. */
    DefaultPropertyAttribute myAttribute = 
       (DefaultPropertyAttribute)attributes[typeof(DefaultPropertyAttribute)];
    Console.WriteLine("The default property is: " + myAttribute.Name);
  
    return 0;
 }


问题


面经


文章

微信
公众号

扫码关注公众号