如何在界面描述语言中表达int []属性?

时间:2009-07-30 19:03:26

标签: c# com idl

如何在IDL中实现此属性:

    public int[] Params
    {
        get
        {
            return _Params;
        }
        set
        {
            _Params = value;
        }
    }

我尝试了下面的idl代码

[propget, helpstring("The click through parameters")] 
    HRESULT Params([out, retval] int *rVal);
[propput, helpstring("The click through parameters")] 
    HRESULT Params([in] int *RnewVal);

但是我的编译器正在寻找这个

public int get_Params()
{
    throw new NotImplementedException();
}

public void set_Params(ref int rVal)
{
    throw new NotImplementedException();
}

我99.999%肯定这是类型的问题。

1 个答案:

答案 0 :(得分:3)

COM typelib导入程序更喜欢处理符合自动化的接口,因此使用SAFEARRAY

[propget, helpstring("The click through parameters")] 
HRESULT Params([out, retval] SAFEARRAY(long) *rVal);

[propput, helpstring("The click through parameters")] 
HRESULT Params([in] SAFEARRAY(long) RnewVal);