using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows; namespace ConsoleApplication1
{ class Person
{ public Person()
{
list = new HashSet<int>();
}
public int age { set; get; }
public string name { set; get; } public ICollection<int> list { set; get; } public override int GetHashCode()
{
int prime = ;
int result = ;
result = prime * result + ((list == null) ? : list.GetHashCode());
result = prime * result + age;
result = prime * result + ((name == null) ? : name.GetHashCode());
return result;
} public override bool Equals(object obj)
{
if (this == obj)
return true;
if (obj == null)
return false;
if (this.GetType() != obj.GetType())
return false;
Person other = (Person)obj;
if (list == null)
{
if (other.list != null)
return false;
}
//else if (!list.Equals(other.list))
// return false; else if (!(list.Except(other.list).Count().Equals() && other.list.Except(list).Count().Equals()))
return false;
if (age != other.age)
return false;
if (name == null)
{
if (other.name != null)
return false;
}
else if (!name.Equals(other.name))
return false;
return true;
}
}
class Program
{
static void Main(string[] args)
{ //HashSet<int> s1 = new HashSet<int>();
//HashSet<int> s2 = new HashSet<int>();
//s1.Add(1);
//s1.Add(2);
//s1.Add(3);
//s2.Add(1);
//s2.Add(2); //var list3 = s2.Except(s1).ToList(); //Console.WriteLine(list3.Count().Equals(0)); //foreach (var i in list3)
//{
//Console.WriteLine(i.ToString());
//}
Person p1 = new Person(); Person p2 = new Person(); p1.name = "aaa";
p1.age = ;
p1.list.Add();
p1.list.Add(); p2.name = "aaa";
p2.age = ;
p2.list.Add();
p2.list.Add(); Console.WriteLine(p1.Equals(p2)); //var t = p1.GetType();
//var p1Model = Activator.CreateInstance(t); //var pros = t.GetProperties(); //int total = pros.Count();
//Console.WriteLine("total: "+total);
//var t2 = p2.GetType();
//var p2Model = Activator.CreateInstance(t2);
//var pros2 = t2.GetProperties(); //bool flag = false; //for (int i = 0; i < total; i++)
//{
// Console.WriteLine(pros[i].GetValue(p1, null) + "---" + pros2[i].GetValue(p2, null));
// if (pros[i].GetValue(p1,null).ToString() != pros2[i].GetValue(p2,null).ToString())
// {
// Console.WriteLine("In if"+pros[i].GetValue(p1, null) + "---" + pros2[i].GetValue(p2, null));
// flag = true;
// }
//}
//Console.WriteLine(flag); //Person p1 = new Person(); //Person p2 = new Person(); //p1.name = "aaa";
//p1.age = 21; //p2.name = "aaa";
//p2.age = 21; //Console.WriteLine(p1.Equals(p2)); //var p1Type = p1.GetType();
//var p2Type = p2.GetType(); //var p1Properties = p1Type.GetProperties();
//var p2Properties = p2Type.GetProperties(); //var type = typeof(Person); //var result = p1Properties.All(p => p2Properties.Where(q => q.Name == p.Name).FirstOrDefault().GetValue(p2).Equals(p.GetValue(p1)));
//Console.WriteLine(result);
Console.ReadKey(); }
}
}

最新文章

  1. 输入DStream和Receiver详解
  2. kuangbin_ShortPath M (POJ 1062)
  3. Java [Leetcode 219]Contains Duplicate II
  4. Kali2.0 Sqlmap清除历史扫描日志
  5. mysql redo log
  6. lesson7:java线程池
  7. W - stl 的 优先队列 Ⅲ
  8. iTextSharp使用字体设置摘录
  9. Head First 设计模式 第3章 装饰者模式
  10. USACO 状压DP练习[3]
  11. Windows下使用Sublime text3快速编辑Linux文件,写Shell
  12. 003 css总结
  13. Kafka笔记7(构建数据管道)
  14. Java中java.util.concurrent包下的4中线程池代码示例
  15. fcagte.exe应用程序错误
  16. icpc2018-焦作-F Honeycomb bfs
  17. CF815D Karen and Cards
  18. 飘逸的python - 中文编码长度有趣的现象
  19. SPSS-单因素方差分析(ANOVA) 案例解析
  20. exception java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11GraphicsEnvironment

热门文章

  1. uC/OS-II 移植笔记
  2. 【转】JS设计模式开篇
  3. 编译安装vim8.0
  4. delphi 单例模式实现
  5. javascript 工具方法(长期更新)
  6. oracle ibatis 存储过程 返回游标 嵌套表
  7. java实现简单的素数判断
  8. 腾讯云centos6.5下部署django环境
  9. Cocos2d-x——Cocos2d-x 屏幕适配新解 – 兼容与扩展【转载】
  10. Squid代理服务器&amp;&amp;搭建透明代理网关服务器