【发布时间】:2012-02-04 17:44:24
【问题描述】:
我试图在 C# 中重载一个适用于 Lists 的运算符(不要问为什么!)。例如,我希望能够写:
List<string> x = // some list of things
List<string> y = // some list of things
List<string> z = x + y
所以'z'包含'x'的所有内容,然后是'y'的内容。我知道已经有组合两个列表的方法,我只是想了解运算符重载如何与泛型结构一起工作。
(顺便说一下,这是来自Systems.Collections.Generic 的List 类。)
【问题讨论】:
-
List在您的示例中是您自己的实现吗?还是来自System.Collections.Generic命名空间? -
来自 System.Collections.Generic。