加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

什么是C#中的DispId注释?

发布时间:2020-12-15 06:29:03 所属栏目:百科 来源:网络整理
导读:例如 public interface IWMPSettings [DispId(101)] bool autoStart { get; set; } [DispId(102)] int balance { get; set; } 它是有用的还是只是自动生成编译器? 解决方法 总之,是的,它是有用的,但只有COM发送: The DispIdAttribute(来自MSDN): Specifie
例如
public interface IWMPSettings

        [DispId(101)]
        bool autoStart { get; set; }
        [DispId(102)]
        int balance { get; set; }

它是有用的还是只是自动生成编译器?

解决方法

总之,是的,它是有用的,但只有COM发送:

The DispIdAttribute(来自MSDN):

Specifies the COM dispatch identifier (DISPID) of a method,field,or property.

This attribute contains the DISPID for the method,or property it describes. Unique DISPIDs are typically assigned by the common language runtime,but you can use this attribute to assign a specific DISPID to a method. When importing a type library,this attribute is applied to all methods with assigned DISPIDs. This ensures that any managed implementation of the same method retains the same DISPID if exposed to COM.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读