├── Records
├── Records.csproj
├── Records.sln
└── Program.cs
├── InitOnlySetters
├── InitOnlySetters.csproj
├── InitOnlySetters.sln
└── Program.cs
├── TopLevelProgram
├── TopLevelProgram.csproj
├── Program.cs
└── TopLevelProgram.sln
├── CovariantReturns
├── CovariantReturns.csproj
├── CovariantReturns.sln
└── Program.cs
├── DefaultConstraint
├── DefaultConstraint.csproj
├── DefaultConstraint.sln
└── Program.cs
├── ImprovedTargetTyping
├── ImprovedTargetTyping.csproj
├── Program.cs
└── ImprovedTargetTyping.sln
├── NativeSizedIntegers
├── NativeSizedIntegers.csproj
├── NativeSizedIntegers.sln
└── Program.cs
├── ExtendedPartialMethods
├── ExtendedPartialMethods.csproj
├── Program.cs
└── ExtendedPartialMethods.sln
├── ExtensionGetEnumerator
├── ExtensionGetEnumerator.csproj
├── ExtensionGetEnumerator.sln
└── Program.cs
├── RecordsAndInheritance
├── RecordsAndInheritance.csproj
├── Program.cs
└── RecordsAndInheritance.sln
├── ImprovedPatternMatching
├── ImprovedPatternMatching.csproj
├── ImprovedPatternMatching.sln
└── Program.cs
├── LambdaDiscardParameters
├── LambdaDiscardParameters.csproj
├── Program.cs
└── LambdaDiscardParameters.sln
├── AttributesOnLocalFunctions
├── AttributesOnLocalFunctions.csproj
├── Program.cs
└── AttributesOnLocalFunctions.sln
├── UnconstrainedTypeParameters
├── UnconstrainedTypeParameters.csproj
├── UnconstrainedTypeParameters.sln
└── Program.cs
├── ConstructorsAndDeconstructorsInRecords
├── ConstructorsAndDeconstructorsInRecords.csproj
├── ConstructorsAndDeconstructorsInRecords.sln
└── Program.cs
├── StaticAnonymousFunctions
├── StaticAnonymousFunctions.csproj
├── Program.cs
└── StaticAnonymousFunctions.sln
├── FunctionPointers
├── FunctionPointers.csproj
├── Program.cs
└── FunctionPointers.sln
├── README.md
└── .gitignore
/Records/Records.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net5.0
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/InitOnlySetters/InitOnlySetters.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net5.0
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/TopLevelProgram/TopLevelProgram.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net5.0
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/CovariantReturns/CovariantReturns.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net5.0
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/DefaultConstraint/DefaultConstraint.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net5.0
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ImprovedTargetTyping/ImprovedTargetTyping.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net5.0
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/NativeSizedIntegers/NativeSizedIntegers.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net5.0
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ExtendedPartialMethods/ExtendedPartialMethods.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net5.0
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ExtensionGetEnumerator/ExtensionGetEnumerator.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net5.0
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/RecordsAndInheritance/RecordsAndInheritance.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net5.0
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ImprovedPatternMatching/ImprovedPatternMatching.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net5.0
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/LambdaDiscardParameters/LambdaDiscardParameters.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net5.0
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/AttributesOnLocalFunctions/AttributesOnLocalFunctions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net5.0
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/UnconstrainedTypeParameters/UnconstrainedTypeParameters.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net5.0
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ConstructorsAndDeconstructorsInRecords/ConstructorsAndDeconstructorsInRecords.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net5.0
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/StaticAnonymousFunctions/StaticAnonymousFunctions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net5.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/AttributesOnLocalFunctions/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace AttributesOnLocalFunctions
4 | {
5 | // Example from tweet https://twitter.com/okyrylchuk/status/1415385617018490881
6 | class Program
7 | {
8 | static void Main()
9 | {
10 | [Obsolete("Attribute on local function")]
11 | void LocalFunction()
12 | {
13 | Console.WriteLine("Hello World!");
14 | }
15 |
16 | LocalFunction();
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/FunctionPointers/FunctionPointers.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net5.0
6 |
7 |
8 |
9 | true
10 |
11 |
12 |
13 | true
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/TopLevelProgram/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 |
4 | // Example from tweet https://twitter.com/okyrylchuk/status/1413589024464424963
5 |
6 | Console.WriteLine(args);
7 | await Task.Delay(1000);
8 | return 0;
9 |
10 | #region C#8 version
11 | // To run C#8 version uncomment code below, comment C#9 version
12 | // And change netcoreapp3.1 in csproj file
13 | /*class Program
14 | {
15 | static async Task Main(string[] args)
16 | {
17 | Console.WriteLine(args);
18 | await Task.Delay(1000);
19 | return 0;
20 | }
21 | }*/
22 | #endregion
--------------------------------------------------------------------------------
/ExtendedPartialMethods/Program.cs:
--------------------------------------------------------------------------------
1 | namespace ExtendedPartialMethods
2 | {
3 | // Example from tweet https://twitter.com/okyrylchuk/status/1416839495132065793
4 | class Program
5 | {
6 | partial class Example
7 | {
8 | // Other than void return type is allowed
9 | public partial int A();
10 | // Access modifiers are allowed
11 | public partial void B();
12 | // Out params are allowed
13 | public partial void C(out int param);
14 | }
15 |
16 | partial class Example
17 | {
18 | public partial int A() => 0;
19 | public partial void B() { }
20 | public partial void C(out int param)
21 | {
22 | param = 0;
23 | }
24 | }
25 |
26 | static void Main(string[] args)
27 | {
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/ImprovedTargetTyping/Program.cs:
--------------------------------------------------------------------------------
1 | namespace ImprovedTargetTyping
2 | {
3 | // Example from tweet https://twitter.com/okyrylchuk/status/1412139149583437833
4 | // And from tweet https://twitter.com/okyrylchuk/status/1412502863356469253
5 | // To run C#8 version change netcoreapp3.1 in csproj file
6 | class Program
7 | {
8 | class Person { }
9 |
10 | class Student : Person { }
11 |
12 | class Customer : Person { }
13 |
14 | static void Main(string[] args)
15 | {
16 | // Target-typed new expression
17 | Student student = new ();
18 | // Target-typed new expression
19 | Customer customer = new ();
20 | bool isStudent = true;
21 |
22 | // Target-typed conditional ?:
23 | Person person = isStudent ? student : customer;
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/FunctionPointers/Program.cs:
--------------------------------------------------------------------------------
1 | namespace FunctionPointers
2 | {
3 | // Example from tweet https://twitter.com/okyrylchuk/status/1417892125912489985
4 | class Program
5 | {
6 | unsafe class Example
7 | {
8 | // This method has a managed calling convention.
9 | // This is the same as leaving the 'managed' keyword off.
10 | delegate* functionPointer1;
11 |
12 | // The same as functionPointer1, but with explicit 'managed' keyword
13 | delegate* managed functionPointer2;
14 |
15 | // This method will be invoked using whatever the default unmanaged calling
16 | // convention on the runtime platform is. This is platform and architecture
17 | // dependent and is determined by the CLR at runtime.
18 | public delegate* unmanaged functionPointer3;
19 | }
20 |
21 | static void Main(string[] args)
22 | {
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/StaticAnonymousFunctions/Program.cs:
--------------------------------------------------------------------------------
1 | using BenchmarkDotNet.Attributes;
2 | using BenchmarkDotNet.Running;
3 | using System.Collections.Generic;
4 |
5 | namespace StaticAnonymousFunctions
6 | {
7 | // Example from tweet https://twitter.com/okyrylchuk/status/1415008120926097411
8 | class Program
9 | {
10 | [MemoryDiagnoser]
11 | public class Benchmark
12 | {
13 | [Benchmark]
14 | public void AnounymousFunction()
15 | {
16 | var list = new List { 1, 2, 3 };
17 | int y = 2;
18 | list.ForEach(x => x *= y);
19 | }
20 |
21 | [Benchmark]
22 | public void StaticAnounymousFunction()
23 | {
24 | var list = new List { 1, 2, 3 };
25 | const int y = 2;
26 | list.ForEach(static x => x *= y);
27 | }
28 | }
29 |
30 | static void Main(string[] args)
31 | {
32 | BenchmarkRunner.Run();
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/LambdaDiscardParameters/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace LambdaDiscardParameters
4 | {
5 | // Example from tweet https://twitter.com/okyrylchuk/status/1415747088592297986
6 | class Program
7 | {
8 | class Button
9 | {
10 | public event EventHandler Click;
11 | }
12 |
13 | static void Main()
14 | {
15 | void PrintHelloWorld()
16 | {
17 | Console.WriteLine("Hello World!");
18 | }
19 |
20 | Button button = new();
21 | button.Click += (_, _) => PrintHelloWorld();
22 | }
23 |
24 | #region C#8 version
25 | // To run C#8 version uncomment code below, comment C#9 version
26 | // And change netcoreapp3.1 in csproj file
27 | /*static void Main()
28 | {
29 | void PrintHelloWorld()
30 | {
31 | Console.WriteLine("Hello World!");
32 | }
33 |
34 |
35 | var button = new Button();
36 | button.Click += (s, e) => PrintHelloWorld();
37 | }*/
38 | #endregion
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Records/Records.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31410.357
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Records", "Records.csproj", "{B2A8970F-6C32-4D96-9D22-051D4F6FC898}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {B2A8970F-6C32-4D96-9D22-051D4F6FC898}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {B2A8970F-6C32-4D96-9D22-051D4F6FC898}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {B2A8970F-6C32-4D96-9D22-051D4F6FC898}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {B2A8970F-6C32-4D96-9D22-051D4F6FC898}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {CD45F43A-CC24-4700-B7AB-AE25A6E4C2DD}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/RecordsAndInheritance/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace RecordsAndInheritance
4 | {
5 | // Example from tweet https://twitter.com/okyrylchuk/status/1418978770220896257
6 | class Program
7 | {
8 | record Person
9 | {
10 | public string FirstName { get; init; }
11 | public string LastName { get; init; }
12 | }
13 |
14 | record Employee : Person
15 | {
16 | public string Position { get; init; }
17 | }
18 |
19 | static void Main()
20 | {
21 | Person person = new Employee
22 | {
23 | FirstName = "Oleg",
24 | LastName = "Kyrylchuk",
25 | Position = ".NET Developer"
26 | };
27 |
28 | // Hidden virtual method copies the whole record (as Employee)
29 | Person newPerson = person with { LastName = "Bond" };
30 |
31 | Employee employee = newPerson as Employee;
32 | Console.WriteLine(employee.FirstName); // Oleg
33 | Console.WriteLine(employee.LastName); // Bond
34 | Console.WriteLine(employee.Position); // .NET Developer
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/InitOnlySetters/InitOnlySetters.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31410.357
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InitOnlySetters", "InitOnlySetters.csproj", "{124B0450-F994-4DF7-90CF-A8673E06388D}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {124B0450-F994-4DF7-90CF-A8673E06388D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {124B0450-F994-4DF7-90CF-A8673E06388D}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {124B0450-F994-4DF7-90CF-A8673E06388D}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {124B0450-F994-4DF7-90CF-A8673E06388D}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {1EEA9861-FE9F-4F23-8D5A-C4C6EBCA30F0}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/TopLevelProgram/TopLevelProgram.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31410.357
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TopLevelProgram", "TopLevelProgram.csproj", "{B2AC3D9A-B083-4829-AA98-7C941C470BB3}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {B2AC3D9A-B083-4829-AA98-7C941C470BB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {B2AC3D9A-B083-4829-AA98-7C941C470BB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {B2AC3D9A-B083-4829-AA98-7C941C470BB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {B2AC3D9A-B083-4829-AA98-7C941C470BB3}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {3C329066-8D96-4D45-9AEF-E1D662FD9AE4}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/CovariantReturns/CovariantReturns.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31410.357
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CovariantReturns", "CovariantReturns.csproj", "{29AD4C84-8760-498D-A82B-16ADB1F27B93}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {29AD4C84-8760-498D-A82B-16ADB1F27B93}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {29AD4C84-8760-498D-A82B-16ADB1F27B93}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {29AD4C84-8760-498D-A82B-16ADB1F27B93}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {29AD4C84-8760-498D-A82B-16ADB1F27B93}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {2FC5F968-30E9-47FE-AD24-9073F7CBB173}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/FunctionPointers/FunctionPointers.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31410.357
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FunctionPointers", "FunctionPointers.csproj", "{81887F58-A6D2-42A5-89E2-CDD75E964865}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {81887F58-A6D2-42A5-89E2-CDD75E964865}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {81887F58-A6D2-42A5-89E2-CDD75E964865}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {81887F58-A6D2-42A5-89E2-CDD75E964865}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {81887F58-A6D2-42A5-89E2-CDD75E964865}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {DDF61DA8-D4C6-42AD-B36C-FBDAB5CCFB1D}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/DefaultConstraint/DefaultConstraint.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31410.357
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DefaultConstraint", "DefaultConstraint.csproj", "{9F03DA44-CC5B-4F4A-8179-5574A6B4F4C6}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {9F03DA44-CC5B-4F4A-8179-5574A6B4F4C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {9F03DA44-CC5B-4F4A-8179-5574A6B4F4C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {9F03DA44-CC5B-4F4A-8179-5574A6B4F4C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {9F03DA44-CC5B-4F4A-8179-5574A6B4F4C6}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {0B5F0EBD-B71C-44A5-85E9-61C736759DBA}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/ImprovedTargetTyping/ImprovedTargetTyping.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31410.357
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImprovedTargetTyping", "ImprovedTargetTyping.csproj", "{FC5FF2B9-688C-404B-9E67-43E1D7536BA7}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {FC5FF2B9-688C-404B-9E67-43E1D7536BA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {FC5FF2B9-688C-404B-9E67-43E1D7536BA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {FC5FF2B9-688C-404B-9E67-43E1D7536BA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {FC5FF2B9-688C-404B-9E67-43E1D7536BA7}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {ACCB6367-9F1F-4204-9945-F63E6FDC72FF}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/NativeSizedIntegers/NativeSizedIntegers.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31410.357
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NativeSizedIntegers", "NativeSizedIntegers.csproj", "{1087530F-3204-4609-8B04-FD50131000D3}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {1087530F-3204-4609-8B04-FD50131000D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {1087530F-3204-4609-8B04-FD50131000D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {1087530F-3204-4609-8B04-FD50131000D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {1087530F-3204-4609-8B04-FD50131000D3}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {17E224DB-AA1F-4A15-9270-9B5CF049238B}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/RecordsAndInheritance/RecordsAndInheritance.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31410.357
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RecordsAndInheritance", "RecordsAndInheritance.csproj", "{82195BB6-92C0-4EBA-94BE-6BE35CEEB83B}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {82195BB6-92C0-4EBA-94BE-6BE35CEEB83B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {82195BB6-92C0-4EBA-94BE-6BE35CEEB83B}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {82195BB6-92C0-4EBA-94BE-6BE35CEEB83B}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {82195BB6-92C0-4EBA-94BE-6BE35CEEB83B}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {1ADA6AFC-D83C-45D0-8FCD-FD324E1DDFB9}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/ExtendedPartialMethods/ExtendedPartialMethods.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31410.357
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExtendedPartialMethods", "ExtendedPartialMethods.csproj", "{83AD6399-22A0-4E19-934B-7158185AF3CA}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {83AD6399-22A0-4E19-934B-7158185AF3CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {83AD6399-22A0-4E19-934B-7158185AF3CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {83AD6399-22A0-4E19-934B-7158185AF3CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {83AD6399-22A0-4E19-934B-7158185AF3CA}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {1355E77F-0E42-4581-AE60-350786F58BA0}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/ExtensionGetEnumerator/ExtensionGetEnumerator.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31410.357
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExtensionGetEnumerator", "ExtensionGetEnumerator.csproj", "{2C6EB662-94B0-4964-A04A-3319E9902236}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {2C6EB662-94B0-4964-A04A-3319E9902236}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {2C6EB662-94B0-4964-A04A-3319E9902236}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {2C6EB662-94B0-4964-A04A-3319E9902236}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {2C6EB662-94B0-4964-A04A-3319E9902236}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {777B89A1-8375-4781-953A-7EB94B553341}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/ImprovedPatternMatching/ImprovedPatternMatching.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31410.357
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImprovedPatternMatching", "ImprovedPatternMatching.csproj", "{FFEBDEDA-5CDF-4D2E-BA30-0B9930A726D8}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {FFEBDEDA-5CDF-4D2E-BA30-0B9930A726D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {FFEBDEDA-5CDF-4D2E-BA30-0B9930A726D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {FFEBDEDA-5CDF-4D2E-BA30-0B9930A726D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {FFEBDEDA-5CDF-4D2E-BA30-0B9930A726D8}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {1DC86B5C-971A-4EA7-BBF0-8FEFE954D639}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/LambdaDiscardParameters/LambdaDiscardParameters.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31410.357
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LambdaDiscardParameters", "LambdaDiscardParameters.csproj", "{20E7BAB3-295C-42D9-B6A0-BACA8965F73B}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {20E7BAB3-295C-42D9-B6A0-BACA8965F73B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {20E7BAB3-295C-42D9-B6A0-BACA8965F73B}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {20E7BAB3-295C-42D9-B6A0-BACA8965F73B}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {20E7BAB3-295C-42D9-B6A0-BACA8965F73B}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {CC197D18-DF77-4E72-B436-8660A8FCDDF5}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/StaticAnonymousFunctions/StaticAnonymousFunctions.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31410.357
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StaticAnonymousFunctions", "StaticAnonymousFunctions.csproj", "{A353162E-FCCC-4ED2-B41F-F30824842201}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {A353162E-FCCC-4ED2-B41F-F30824842201}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {A353162E-FCCC-4ED2-B41F-F30824842201}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {A353162E-FCCC-4ED2-B41F-F30824842201}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {A353162E-FCCC-4ED2-B41F-F30824842201}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {1318B82F-E460-4F9C-83AB-51FBC5EF6B48}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/AttributesOnLocalFunctions/AttributesOnLocalFunctions.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31410.357
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AttributesOnLocalFunctions", "AttributesOnLocalFunctions.csproj", "{5BCC21AB-3DE9-45D8-B827-989B333B776F}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {5BCC21AB-3DE9-45D8-B827-989B333B776F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {5BCC21AB-3DE9-45D8-B827-989B333B776F}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {5BCC21AB-3DE9-45D8-B827-989B333B776F}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {5BCC21AB-3DE9-45D8-B827-989B333B776F}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {D77B87B4-7EA3-4164-91BB-344B0010CCC4}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/UnconstrainedTypeParameters/UnconstrainedTypeParameters.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31410.357
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnconstrainedTypeParameters", "UnconstrainedTypeParameters.csproj", "{38F4BF34-71DB-45A4-963C-E958F512484F}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {38F4BF34-71DB-45A4-963C-E958F512484F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {38F4BF34-71DB-45A4-963C-E958F512484F}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {38F4BF34-71DB-45A4-963C-E958F512484F}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {38F4BF34-71DB-45A4-963C-E958F512484F}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {5620116C-1323-41F0-823B-2BAF57051455}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/ConstructorsAndDeconstructorsInRecords/ConstructorsAndDeconstructorsInRecords.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31410.357
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConstructorsAndDeconstructorsInRecords", "ConstructorsAndDeconstructorsInRecords.csproj", "{18DE2553-D44D-475D-B821-9656BCD9198F}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {18DE2553-D44D-475D-B821-9656BCD9198F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {18DE2553-D44D-475D-B821-9656BCD9198F}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {18DE2553-D44D-475D-B821-9656BCD9198F}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {18DE2553-D44D-475D-B821-9656BCD9198F}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {DF4AA832-2E39-44A8-86D7-2E01CBAA24EB}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/ConstructorsAndDeconstructorsInRecords/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ConstructorsAndDeconstructorsInRecords
4 | {
5 | // Example from tweet https://twitter.com/okyrylchuk/status/1418632003004551168
6 | class Program
7 | {
8 | // Positional record
9 | record Person(string FirstName, string LastName);
10 |
11 | /* Usual record
12 | record Person
13 | {
14 | public string FirstName { get; init; }
15 | public string LastName { get; init; }
16 |
17 | // Constructor
18 | public Person(string firstName, string lastName)
19 | => (FirstName, LastName) = (firstName, lastName);
20 |
21 | // Deconstructor
22 | public void Deconstruct(out string firstName, out string lastName)
23 | => (firstName, lastName) = (FirstName, LastName);
24 | }*/
25 |
26 | static void Main()
27 | {
28 | // Construct record
29 | var person = new Person("Oleg", "Kyrylchuk");
30 | Console.WriteLine(person.FirstName);
31 | Console.WriteLine(person.LastName);
32 |
33 | // Deconstruct record
34 | var (firstName, lastName) = person;
35 | Console.WriteLine(firstName);
36 | Console.WriteLine(lastName);
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/InitOnlySetters/Program.cs:
--------------------------------------------------------------------------------
1 | namespace InitOnlySetters
2 | {
3 | // Example from tweet https://twitter.com/okyrylchuk/status/1412848899463733249
4 | class Program
5 | {
6 | class Person
7 | {
8 | public string FirstName { get; init; }
9 | public string LastName { get; init; }
10 | }
11 |
12 | static void Main(string[] args)
13 | {
14 | var person = new Person()
15 | {
16 | FirstName = "Oleg",
17 | LastName = "Kyrylchuk"
18 | };
19 |
20 | person.FirstName = "New first name"; // immutable
21 | person.LastName = "New last name"; // immutable
22 | }
23 | }
24 |
25 | #region C#8 version
26 | // To run C#8 version uncomment code below, comment C#9 version
27 | // And change netcoreapp3.1 in csproj file
28 | //class Program
29 | //{
30 | // class Person
31 | // {
32 | // public string FirstName { get; set; }
33 | // public string LastName { get; set; }
34 | // }
35 |
36 | // static void Main(string[] args)
37 | // {
38 | // var person = new Person()
39 | // {
40 | // FirstName = "Oleg",
41 | // LastName = "Kyrylchuk"
42 | // };
43 |
44 | // person.FirstName = "New first name"; // mutable
45 | // person.LastName = "New last name"; // mutable
46 | // }
47 | //}
48 | #endregion
49 | }
50 |
--------------------------------------------------------------------------------
/NativeSizedIntegers/Program.cs:
--------------------------------------------------------------------------------
1 | namespace NativeSizedIntegers
2 | {
3 | // Example from tweet https://twitter.com/okyrylchuk/status/1417581217420021767
4 | class Program
5 | {
6 | static void Main()
7 | {
8 | // The compiler provides operations and conversions for
9 | // 'nint' and 'nuint' that are appropriate for integer types.
10 | nint a = 10;
11 | nint b = 7;
12 |
13 | _ = a + b;
14 | _ = a - b;
15 |
16 | nuint c = 5;
17 | nuint d = 3;
18 |
19 | _ = c + d;
20 | _ = c - d;
21 | }
22 |
23 | #region C#8 version
24 | // To run C#8 version uncomment code below, comment C#9 version
25 | // And change netcoreapp3.1 in csproj file
26 | /*static void Main()
27 | {
28 | // The native-sized integer types are represented internally
29 | // as the .NET types System.IntPtr and System.UIntPtr.
30 | // Unlike other numeric types, you can't use them as integer types.
31 | IntPtr a = 10; // you can initialize IntPtr a = new IntPtr(10);
32 | IntPtr b = 7; // you can initialize IntPtr a = new IntPtr(7);
33 |
34 | _ = a + b;
35 | _ = a - b;
36 |
37 | UIntPtr c = 5; // you can initialize UIntPtr a = new UIntPtr(5);
38 | UIntPtr d = 3; // you can initialize UIntPtr a = new UIntPtr(3);
39 |
40 | _ = c + d;
41 | _ = c - d;
42 | }*/
43 | #endregion
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/CovariantReturns/Program.cs:
--------------------------------------------------------------------------------
1 | namespace CovariantReturns
2 | {
3 | // Example from tweet https://twitter.com/okyrylchuk/status/1413226380402192385
4 | class Program
5 | {
6 | abstract class Cloneable
7 | {
8 | public abstract Cloneable Clone();
9 | }
10 |
11 | class Person : Cloneable
12 | {
13 | public string Name { get; set; }
14 | public override Person Clone()
15 | {
16 | return new Person { Name = Name };
17 | }
18 |
19 | static void Main(string[] args)
20 | {
21 | Person person = new Person { Name = "Oleg" };
22 | Person clonedPerson = person.Clone();
23 | }
24 | }
25 | }
26 |
27 | #region C#8 version
28 | // To run C#8 version uncomment code below, comment C#9 version
29 | // And change netcoreapp3.1 in csproj file
30 | /*class Program
31 | {
32 | abstract class Cloneable
33 | {
34 | public abstract Cloneable Clone();
35 | }
36 |
37 | class Person : Cloneable
38 | {
39 | public string Name { get; set; }
40 | public override Cloneable Clone()
41 | {
42 | return new Person { Name = Name };
43 | }
44 | }
45 |
46 | static void Main(string[] args)
47 | {
48 | Person person = new Person { Name = "Oleg" };
49 | Person clonedPerson = (Person)person.Clone();
50 | }
51 | }*/
52 | #endregion
53 | }
54 |
--------------------------------------------------------------------------------
/ExtensionGetEnumerator/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ExtensionGetEnumerator
5 | {
6 | // Example from tweet https://twitter.com/okyrylchuk/status/1417205582579306499
7 | public static class Extensions
8 | {
9 | public static IEnumerator GetEnumerator
10 | (this IEnumerator enumerator) => enumerator;
11 | }
12 |
13 |
14 | class Program
15 | {
16 | static void Main()
17 | {
18 | var list = new List { 1, 2, 3 };
19 | IEnumerator enumerator = list.GetEnumerator();
20 | foreach (int i in enumerator)
21 | {
22 | Console.WriteLine(i);
23 | }
24 | // Output:
25 | // 1
26 | // 2
27 | // 3
28 | }
29 |
30 | #region C#8 version
31 | // To run C#8 version uncomment code below, comment C#9 version
32 | // And change netcoreapp3.1 in csproj file
33 | /*static void Main()
34 | {
35 | var list = new List { 1, 2, 3 };
36 | IEnumerator enumerator = list.GetEnumerator();
37 | foreach (int i in enumerator)
38 | {
39 | Console.WriteLine(i);
40 | }
41 | // Compilation error without extension:
42 | // Error CS1579: foreach statement cannot operate on variables of type
43 | // 'IEnumerator' because 'IEnumerator' does not contain a public
44 | // instance definition for 'GetEnumerator'.
45 |
46 | // Compilation error with extension:
47 | // Feature 'extension GetEnumerator()' is not available in C# 8.0.
48 | // Please use language version C# 9.0 or greater.
49 | }*/
50 | #endregion
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/UnconstrainedTypeParameters/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace UnconstrainedTypeParameters
4 | {
5 | // Example from tweet https://twitter.com/okyrylchuk/status/1416125980368936967
6 | class Program
7 | {
8 | #nullable enable
9 | class Example
10 | {
11 | // no overloads
12 | // handle both reference and value types
13 | public void DoSomething(T? param)
14 | { }
15 | }
16 |
17 | static void Main()
18 | {
19 | var example = new Example();
20 |
21 | // reference type, not null
22 | example.DoSomething(new object());
23 | // reference type, null
24 | example.DoSomething