例如
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.