IEnumerable类型原生是没有Add方法的,你可以用Contact方法去为它添加元素,

items = items.Concat(new[] { "foo" });

也可以用个扩展方法:

public static IEnumerable<T> Add<T>(this IEnumerable<T> e, T value) {
  foreach ( var cur in e) {
    yield return cur;
  }
  yield return value;
}

相关文章:

  • 2021-10-12
  • 2022-01-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-11
  • 2021-10-06
  • 2021-10-31
  • 2022-02-12
猜你喜欢
  • 2021-08-24
  • 2021-05-23
  • 2022-12-23
  • 2021-04-27
  • 2022-12-23
  • 2021-08-04
  • 2022-12-23
相关资源
相似解决方案