什么是用C#DISPID注释?

编程入门 行业动态 更新时间:2024-10-23 23:29:03
本文介绍了什么是用C#DISPID注释?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

例如

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

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

is it useful or is it just auto-generated for compiler?

推荐答案

总之,是的,它是有用的,但只适用于COM调度:

In short, yes it is useful, but only for COM dispatch:

The DispIdAttribute (从MSDN):

指定COM调度标识符的方法,字段或属性(DISPID)。

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

这个属性包含D​​ISPID的方法,字段或属性它描述。独特的DISPID一般会分配由公共语言运行库,但你可以使用这个属性来指定DISPID分配的方法。当导入类型库,这个属性被应用到与分配的DISPID的所有方法。这确保相同的方法中的任何管理执行保留相同的DISPID如果暴露在COM

This attribute contains the DISPID for the method, field, 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.

更多推荐

什么是用C#DISPID注释?

本文发布于:2023-11-07 22:43:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1567639.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:注释   DISPID

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!