
在使用IEnumerable的Append方法追加元素时:
- class Program {
- static void Main(string[] args) {
- //
- // 摘要:
- // Appends a value to the end of the sequence.
- //
- // 参数:
- // source:
- // A sequence of values.
- //
- // element:
- // The value to append to source.
- //
- // 类型参数:
- // TSource:
- // The type of the elements of source.
- //
- // 返回结果:
- // A new sequence that ends with element.
- //
- // 异常:
- // T:System.ArgumentNullException:
- // source is null.
- //public static IEnumerable<TSource> Append<TSource>(this IEnumerable<TSource> source, TSource element);
-
- IEnumerable<People> peoples = new List<People>();
- People people = new People() { Id = 1, Name = "黄大仙1" };
- // 直接添加:peoples中呈现出来的效果是没有将people添加进去
- peoples.Append<People>(people);
-
- // 接收添加后返回的结果:此时,result中可以看到包含了添加的people
- var result = peoples.Append<People>(people);
-
- // 总结:通过Append函数的摘要可以看出:
- // Appends a value to the end of the sequence.(添加一个值到序列的结尾)
- // A new sequence that ends with element.(返回一个结尾元素包含添加对象的新的序列)
- // 所以我们需要通过一个新的对象来接收返回的新序列
-
- Console.ReadKey();
- }
- }
-
- public class People {
- public int Id { get; set; }
-
- public String Name { get; set; }
- }
评价
排名
35
文章
15
粉丝
5
评论
5
通过Windows服务进行FTP与服务器之间文件的传输
剑轩 : 内容是真的长!
vue.js 学习日记第五章-v-if和v-for指令的使用方式
饰心 : 吃惊!博客更新小王子?
vue.js 学习日记第三章-vue中的简单事件及事件修饰符
修心 : 一个专栏可以的!说一下前端的mvc就更好了
通过PlUpload控件配合WebApi接口完成压缩上传文件
剑轩 : 厉害了,这个很实用。这个可以实现图片压缩?
C#+selenium实现自动登录
剑轩 : 坐标不能是线性的,因为人拖动的时候不是线性的。可以试下这个思路...
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2025TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
公网安备:
50010702506256


欢迎加群交流技术