-
Notifications
You must be signed in to change notification settings - Fork 37
/
StaticClass.cs
77 lines (69 loc) · 2.46 KB
/
StaticClass.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
68
69
70
71
72
73
74
75
76
77
//____________________________________________________________________________________________________________________________________
//
// Copyright (C) 2024, Mariusz Postol LODZ POLAND.
//
// To be in touch join the community by pressing the `Watch` button and get started commenting using the discussion panel at
//
// https://github.com/mpostol/TP/discussions/182
//
// by introducing yourself and telling us what you do with this community.
//_____________________________________________________________________________________________________________________________________
namespace TP.FunctionalProgramming
{
/// <summary>
/// Class StaticClass - demonstrates:
/// - initialization issues for static class
/// - custom serialization
/// - state representation
/// - API representation
/// </summary>
public static class StaticClass//: ISerializable - 'StaticClass': static classes cannot implement interfaces
{
//Initialization:
/// <summary>
/// Static classes cannot have instance constructors
/// </summary>
//public StaticClass() { }
/// <summary>
/// 'StaticClass.StaticClass(double)': a static constructor must be parameterless
/// </summary>
//static StaticClass(double x) { }
/// <summary>
/// It is called automatically before any member is referenced. A static constructor is used to initialize any static data,
/// or to perform a particular action that needs to be performed only once.
/// </summary>
static StaticClass()
{
MaxIncome = 987654.321;
MinIncome = 123456.789;
}
/// <summary>
/// Static initializer of the class.
/// </summary>
/// <param name="MaxIncome">The maximum income.</param>
/// <param name="MinIncome">The minimum income.</param>
public static void StaticClassInitializer(double maxIncome, double minIncome)
{
MaxIncome = maxIncome;
MinIncome = minIncome;
}
/// <summary>
/// Gets or sets the maximum income.
/// </summary>
/// <value>The maximum income.</value>
public static double MaxIncome { get; set; }
/// <summary>
/// Gets or sets the minimum income.
/// </summary>
/// <value>The minimum income.</value>
public static double MinIncome { get; set; }
/// <summary>
/// Gets the average income.
/// </summary>
/// <value>The average income.</value>
public static double AverageIncome
{
get { return (MaxIncome + MinIncome) / 2; }
}
}
}