-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.cs
More file actions
58 lines (49 loc) · 1.37 KB
/
Test.cs
File metadata and controls
58 lines (49 loc) · 1.37 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
48
49
50
51
52
53
54
55
56
57
58
using System;
using static System.Console;
namespace StandAloneCSharpParser
{
public class Test
{
public bool IsPositive(int input)
{
return input > 0;
}
public delegate bool isPos(int input);
public Test()
{
isPos del = IsPositive;
int two = 2;
WriteLine($"\n 2 is positive = {del(two)}");
}
}
public class SampleEventArgs
{
public SampleEventArgs(string text) { Text = text; }
public string Text { get; } // readonly
}
public class Publisher
{
public delegate void SampleEventHandler(object sender, SampleEventArgs e);
public event SampleEventHandler SampleEvent;
protected virtual void RaiseSampleEvent()
{
// Raise the event in a thread-safe manner using the ?. operator.
SampleEvent?.Invoke(this, new SampleEventArgs("Hello"));
}
}
class TimePeriod
{
private double _seconds;
public int minutes { get; set; }
public double Hours
{
get { return _seconds / 3600; }
set
{
if (value < 0 || value > 24)
throw new ArgumentOutOfRangeException($"{nameof(value)} must be between 0 and 24.");
_seconds = value * 3600;
}
}
}
}