-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHash_Code.cs
More file actions
49 lines (34 loc) · 1.04 KB
/
Hash_Code.cs
File metadata and controls
49 lines (34 loc) · 1.04 KB
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
using System;
using System.Collections.Generic;
using System.IO;
namespace TrabajoLab
{
class Program
{
class Person
{
public string fname, lname;
public Person(string fname, string lname)
{
this.fname = fname;
this.lname = lname;
}
public override int GetHashCode()
{
return fname.GetHashCode() + lname.GetHashCode() * 31;
}
}
static void Main(string[] args)
{
Dictionary<Person, double> indice = new Dictionary<Person, double>();
Person Jesus = new Person("Jesus", "Cristo");
Person Jesus1 = new Person("Jesus", "Cristo");
Person Pedro = new Person("Pedro", "Cristo");
indice.Add(Jesus, 4.0);
Console.WriteLine(indice.ContainsKey(Jesus1));
Console.WriteLine(indice.ContainsKey(Pedro));
Console.WriteLine(Jesus.Equals(Pedro));
Console.Read();
}
}
}