-
Notifications
You must be signed in to change notification settings - Fork 0
/
PropertiesSample.cs
50 lines (44 loc) · 1.57 KB
/
PropertiesSample.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
using System;
namespace CodeSamples.SyntacticSugars
{
public class PropertiesSample: SampleExecute
{
#region Property Assignment
private string _propertyName = "value";
//property getters/setter
public string PropertyNameLong
{
get
{
return _propertyName;
}
set
{
_propertyName = value;
}
}
//property short
public string PropertyNameShort
{
get => _propertyName;
set => _propertyName = value;
}
//expression bodied members
public string ExpressionMember => $"{PropertyNameLong} {PropertyNameShort}";
#endregion
public string AutoProperty { get; set; }
public string AutoPropertyDefaultValueEmpty { get; set; } = String.Empty;
public string AutoPropertyDefaultValueNotEmpty { get; set; } = "default property value";
public override void Execute()
{
Title("PropertiesExecute");
Console.WriteLine($"PropertyNameLong = {PropertyNameLong}");
Console.WriteLine($"PropertyNameShort = {PropertyNameShort}");
Console.WriteLine($"ExpressionMember = {ExpressionMember}");
Console.WriteLine($"AutoProperty = {AutoProperty}");
Console.WriteLine($"AutoPropertyDefaultValueEmpty = {AutoPropertyDefaultValueEmpty}");
Console.WriteLine($"AutoPropertyDefaultValueNotEmpty = {AutoPropertyDefaultValueNotEmpty}");
Finish();
}
}
}