-
Notifications
You must be signed in to change notification settings - Fork 0
/
Person.cs
60 lines (49 loc) · 1.99 KB
/
Person.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
namespace PetManager {
public class Person {
// das ist ein kommentar
// add hashcode
public override int GetHashCode()
{
unchecked // Overflow is fine, just wrap
{
int hash = 17;
hash = hash * 23 + (this.Lastname != null ? this.Lastname.GetHashCode() : 0);
hash = hash * 23 + (this.Firstname != null ? this.Firstname.GetHashCode() : 0);
hash = hash * 23 + (this.Pets != null ? this.Pets.GetHashCode() : 0);
return hash;
}
}
public Person() {
this.Pets = new BindingList<Pet>();
}
public string Lastname { get; set; }
public string Firstname { get; set; }
public BindingList<Pet> Pets { get; private set; }
public static BindingList<Person> GetDemoData() {
var ret = new BindingList<Person>();
var person = new Person() {Lastname = "Müller", Firstname = "Max"};
person.Pets.Add(new Pet { Name = "Cäsar", Breed = "Kanarienvogel"});
person.Pets.Add(new Pet { Name = "Bello", Breed = "Hund" });
ret.Add(person);
person = new Person() { Lastname = "Doe", Firstname = "John" };
person.Pets.Add(new Pet { Name = "Fleckli", Breed = "Kaninchen" });
person.Pets.Add(new Pet { Name = "Hoppel", Breed = "Kaninchen" });
person.Pets.Add(new Pet { Name = "Wau", Breed = "Hund" });
ret.Add(person);
return ret;
}
public override bool Equals(object obj) {
if (!(obj is Person)) {
return object.Equals(obj, this);
}
var person = (Person) obj;
return string.Equals(this.Lastname, person.Lastname) && string.Equals(this.Firstname, person.Firstname);
}
}
}