c#---List共享空间的情况
2016-03-26 16:39
316 查看
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace rand { class Program { class E { public int a; public int b; public E(int aa, int bb) { a = aa; b = bb; } } static void Main(string[] args) { List<E> l = new List<E>(); E A = new E(1, 2); l.Add(A); List<E> ll = new List<E>(l); //!!!! ll[0].a = 4; //!!!! Console.WriteLine(l[0].a); //结果为4,而不是原来的1 Console.ReadLine(); } } }
static void Main(string[] args) { E A = new E(1, 2); E D = A; //!!!!! D.a = 4; //!!!!! Console.WriteLine(A.a); //结果为4,而不是原来的1 Console.ReadLine(); }
static void Main(string[] args) { List<E> l = new List<E>(); E A = new E(1, 2); l.Add(A); List<E> ll = new List<E>(); E C = new E(1, 1); //!!!!!! C = l[0]; //!!!!!! C.a = 4; //!!!!!! ll.Add(C); Console.WriteLine(l[0].a); //结果为4,而不是原来的1 Console.ReadLine(); }
相关文章推荐
- 网速监控 v1.6.1(C#,源代码)
- 学习笔记整理之C#
- C#第三次上机
- C# 三种字节数组(byte[])拼接的性能对比测试
- C#简单实现在网页上发邮件的案例
- C#简单判断文件的编码格式
- C# 图片处理心得
- [C#]第30位数字是多少
- C#第二次上机
- C#第一次上机
- C#中的OLEDB连接2
- C#制作视频播放器-player播放器组件
- C# 编写WCF简单的服务端与客户端
- c#单例模式3中写法
- C#扫盲之:String字符串的常用方法和冷知识
- C# .net 下拉框显示提示内容-【ComboBox】
- C#界面美工IrisSkin2+button美工
- 我为什么喜欢用C#来做并发编程
- C#Winform内存加载多条件查询数据
- C#程序层面的内存分页方法