【发布时间】:2015-03-04 10:37:25
【问题描述】:
如何在 C++/CLI - 接口中声明默认索引属性。
(请原谅重复的、完全限定的命名空间符号,因为我只是在学习 C++/CLI,并希望确保不会发生 C++ 和 C# 之间的语言原语意外混淆)
代码是
public interface class ITestWithIndexer
{
property System::String ^ default[System::Int32];
}
编译器总是抛出“error C3289: 'default' a trivial property cannot be indexed”。
我的错误在哪里?
PS:在 C# 中,它只是
public interface ITestWithIndexer
{
System.String this[System.Int32] { get; set; }
}
如何将其翻译成 C++/CLI?
谢谢!!
【问题讨论】:
标签: properties interface c++-cli default indexer