我想继承某种数组/向量/列表类,这样我就可以添加一个额外的专用方法….像这样:
public class SpacesArray : ArrayList<Space> { public Space this[Color c,int i] { get { return this[c == Color.White ? i : this.Count - i - 1]; } set { this[c == Color.White ? i : this.Count - i - 1] = value; } } }
但编译器不会让我.说
The non-generic type ‘System.Collections.ArrayList’ cannot be used with type arguments
我该如何解决这个问题?
解决方法
ArrayList不是通用的.使用列表< Space>来自System.Collections.Generic.
原文地址:https://www.jb51.cc/csharp/98161.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。