【发布时间】:2018-12-17 17:37:28
【问题描述】:
我正在尝试编写和代理具有
的 ImmutableListpublic ref readonly T ItemRef(int index);
我试试:
public class MyImmutableList<T> {
public readonly ImmutableList<T> Value;
...
public ref readonly T ItemRef(int index) => Value.ItemRef(index);
}
我明白了:
按值返回只能用于按值返回的方法
这里有什么问题?以及如何解决这个问题?
【问题讨论】:
-
public ref readonly T ItemRef(int index) => ref Value.ItemRef(index);? -
太棒了,编译!你能发布答案吗