-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
36 lines (32 loc) · 1.04 KB
/
Program.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 InParameterModifier
{
/// <summary>
/// https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/in-parameter-modifier
/// https://stackoverflow.com/questions/52820372/why-would-one-ever-use-the-in-parameter-modifier-in-c
/// https://github.com/dotnet/csharplang/issues/1133
/// </summary>
class Program
{
static void Main(string[] args)
{
var person = new Person("Emine", "ATAY");
Print(person);
}
static void Print(in Person person)
{
//person.FirstName = "Emine"; // compilation error
//person = new Person("Test", "Test"); // compilation error
Console.WriteLine(person.ToString());
}
readonly struct ImmutableObject
{
public readonly long Val01;
public readonly long Val02;
}
}
record Person(string FirstName, string LastName)
{
public override string ToString() => $"{FirstName} {LastName}";
}
}