-
Notifications
You must be signed in to change notification settings - Fork 0
/
State.cs
67 lines (60 loc) · 3.34 KB
/
State.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
61
62
63
64
65
66
67
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace interweb.CalendarCalculator
{
/******************************************************************************************************************
* This class holds states/province of a country for holiday-assignment
*
* Methods GetHashCode and Equals are overwritten, because this class is used for a dictionary key as well.
* This is not usual, but it works perfectly. The key id for the dictionary is the state id and an exception
* is thrown, when you try to add a state (ID) to the dictionary list twice.
*
* Last update: 15.05.2010
******************************************************************************************************************/
//-----------------------------------------------------------------------------------------------------------------
public class State : IEquatable<State>
//-----------------------------------------------------------------------------------------------------------------
{
int _stateID; // e. g. 2
string _stateName; // e. g. "Bavaria"
//-----------------------------------------------------------------------------------------------------------------
public State(int stateID, string stateName)
//-----------------------------------------------------------------------------------------------------------------
{
this._stateID = stateID;
this._stateName = stateName;
}
//-----------------------------------------------------------------------------------------------------------------
public int StateID
//-----------------------------------------------------------------------------------------------------------------
{
get { return this._stateID; }
}
//-----------------------------------------------------------------------------------------------------------------
public string StateName
//-----------------------------------------------------------------------------------------------------------------
{
get { return this._stateName; }
}
//-----------------------------------------------------------------------------------------------------------------
public override int GetHashCode()
//-----------------------------------------------------------------------------------------------------------------
{
return( this.StateID );
}
//-----------------------------------------------------------------------------------------------------------------
public override bool Equals(object obj)
//-----------------------------------------------------------------------------------------------------------------
{
return( Equals(obj as State) );
}
//-----------------------------------------------------------------------------------------------------------------
public bool Equals(State obj)
//-----------------------------------------------------------------------------------------------------------------
{
return( obj != null && obj.StateID == this.StateID );
}
}
}