-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSample0.cs
36 lines (32 loc) · 968 Bytes
/
Sample0.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
using System;
namespace csharp9.Test_Class
{
//class NORMALE CON PROP get/set PER CONSENTIRE SINTASSI object-initializer
class Person
{
public string Firstname { get; set; } = "";
public string Lastname { get; set; } = "";
}
public static class Sample0
{
public static void Run()
{
Console.Write($"\n{nameof(Sample0)}\n{"".PadRight(80, '_')}\n");
//SINTASSI object-initializer
var p = new Person
{
Lastname = "Paperone",
Firstname = "Zio"
};
DisplayPerson(p);
//NOTARE PROBLEMA PROP mutation
p.Lastname = "Paperino";
DisplayPerson(p);
Console.Write($"{"".PadRight(80, '=')}\n\n\n");
}
static void DisplayPerson(Person p)
{
Console.WriteLine($"Ciao @{p.GetType().FullName}: {p.Firstname} {p.Lastname}");
}
}
}