├── csharp11
├── 8. File scoped types
│ ├── Builder.cs
│ ├── GeneratedBuilder.cs
│ └── 8. File scoped types.csproj
├── 3. Newlines in string interpolations
│ ├── Program.cs
│ └── 3. Newlines in string interpolations.csproj
├── 7. Utf8 String Literals
│ ├── Program.cs
│ └── 7. Utf8 String Literals.csproj
├── 4. List patterns
│ ├── 4. List patterns.csproj
│ └── Program.cs
├── 2. Generic Attributes
│ ├── 2. Generic Attributes.csproj
│ └── Program.cs
├── 5. RawStringLiterals
│ ├── 5. Raw String Literals.csproj
│ └── Program.cs
├── 1. Auto Default Structs
│ ├── 1. Auto Default Structs.csproj
│ └── Program.cs
├── 6. Generic math support
│ ├── 6. Generic math support.csproj
│ └── Program.cs
├── 9. Required Properties
│ ├── 9. Required Properties.csproj
│ └── Program.cs
├── Csharp11.sln
└── ReadMe.md
├── csharp9
├── 1. TopLevelStatement
│ ├── Program.cs
│ └── 1. TopLevelStatement.csproj
├── 2. Records
│ ├── 2. Records.csproj
│ └── Program.cs
├── 3. TargetTypedObject
│ ├── 3. TargetTypedObject.csproj
│ └── Program.cs
├── 4. InitOnlySetters
│ ├── 4. InitOnlySetters.csproj
│ └── Program.cs
├── 7. CovariantReturns
│ ├── 7. CovariantReturns.csproj
│ └── Program.cs
├── 6. ExtendedPartialMethods
│ ├── 6. ExtendedPartialMethods.csproj
│ └── Program.cs
├── 5. RelationalAndLogicalPatterns
│ ├── 5. RelationalAndLogicalPatterns.csproj
│ └── Program.cs
├── CSharp9Features.sln
└── ReadMe.md
├── csharp10
├── 4. Records
│ ├── Point.cs
│ ├── 4. Records.csproj
│ └── Circle.cs
├── 6. Global Using directive
│ ├── GlobalUsings.cs
│ ├── Author.cs
│ ├── Store.cs
│ ├── 6. Global Using directive.csproj
│ └── Book.cs
├── 7. Structure Types
│ ├── Program.cs
│ ├── 7. Structure Types.csproj
│ └── Point.cs
├── 1. File-Scoped Namespace
│ ├── Book.cs
│ ├── Author.cs
│ └── 1. File-Scoped Namespace.csproj
├── Csharp10
│ ├── Program.cs
│ └── 0. Console Template.csproj
├── 2. Extended Property Patterns
│ ├── Author.cs
│ ├── 2. Extended Property Patterns.csproj
│ └── Book.cs
├── 3. Constant Interpolated Strings
│ ├── Author.cs
│ ├── 3. Constant Interpolated Strings.csproj
│ └── Book.cs
├── 5. Deconstruction
│ ├── 5. Deconstruction.csproj
│ ├── Author.cs
│ └── Program.cs
├── Csharp10.sln
└── ReadMe.md
├── csharp12
├── 8. Interceptors
│ ├── Program.cs
│ ├── Sender.cs
│ ├── InterceptsLocationAttribute.cs
│ ├── Hacker.cs
│ └── 8. Interceptors.csproj
├── 5. Default lambda parameters
│ ├── Program.cs
│ └── 5. Default lambda parameters.csproj
├── 1. Alias any type
│ ├── Program.cs
│ └── 1. Alias any type.csproj
├── 7. Experimental attribute
│ ├── Program.cs
│ └── 7. Experimental attribute.csproj
├── 4. Inline arrays
│ ├── Program.cs
│ └── 4. Inline arrays.csproj
├── 6. Ref readonly
│ ├── 6. Ref readonly.csproj
│ └── Program.cs
├── 2. Primary constructors
│ ├── 2. Primary constructors.csproj
│ └── Program.cs
├── 3. Collection expressions
│ ├── 3. Collection expressions.csproj
│ └── Program.cs
├── csharp12-features.sln
└── ReadMe.md
├── csharp13
├── 4. New Escape Sequence
│ ├── Program.cs
│ └── 4. New Escape Sequence.csproj
├── 1. Params Collections
│ ├── Program.cs
│ └── 1. Params Collections.csproj
├── 3. New Lock Object
│ ├── 3. New Lock Object.csproj
│ └── Program.cs
├── 8. Allows Ref Struct
│ ├── 8. Allows Ref Struct.csproj
│ └── Program.cs
├── 10. More Partial Members
│ ├── 10. More Partial Members.csproj
│ └── Program.cs
├── 11. Field Keyword
│ ├── 11. Field Keyword.csproj
│ └── Program.cs
├── 6. Implicit Index Access
│ ├── 6. Implicit Index Access.csproj
│ └── Program.cs
├── 9. Ref Struct Interfaces
│ ├── 9. Ref Struct Interfaces.csproj
│ └── Program.cs
├── 5. Method Group Natural Type
│ ├── 5. Method Group Natural Type.csproj
│ └── Program.cs
├── 2. Overload Resolution Priority
│ ├── 2. Overload Resolution Priority.csproj
│ └── Program.cs
├── 7. Ref and Unsafe in Async and Iterators
│ ├── 7. Ref and Unsafe in Async and Iterators.csproj
│ └── Program.cs
├── csharp13-features.sln
└── ReadMe.md
├── README.md
└── .gitignore
/csharp11/8. File scoped types/Builder.cs:
--------------------------------------------------------------------------------
1 | class Builder
2 | {
3 | }
4 |
--------------------------------------------------------------------------------
/csharp11/8. File scoped types/GeneratedBuilder.cs:
--------------------------------------------------------------------------------
1 | file class Builder
2 | {
3 | }
4 |
--------------------------------------------------------------------------------
/csharp9/1. TopLevelStatement/Program.cs:
--------------------------------------------------------------------------------
1 | System.Console.WriteLine("Hello World!");
2 |
--------------------------------------------------------------------------------
/csharp10/4. Records/Point.cs:
--------------------------------------------------------------------------------
1 | namespace _4._Records;
2 |
3 | public readonly record struct Point(int X, int Y);
4 |
--------------------------------------------------------------------------------
/csharp12/8. Interceptors/Program.cs:
--------------------------------------------------------------------------------
1 | using _8._Interceptors;
2 |
3 | var sender = new Sender();
4 | sender.SendMessage();
--------------------------------------------------------------------------------
/csharp10/6. Global Using directive/GlobalUsings.cs:
--------------------------------------------------------------------------------
1 | global using System.Collections.Generic;
2 | global using System.Linq;
3 |
4 |
--------------------------------------------------------------------------------
/csharp13/4. New Escape Sequence/Program.cs:
--------------------------------------------------------------------------------
1 | const string previousEscape = "\u001b";
2 | const string previousEscapeNotRecommended = "\x1b";
3 | const string newEscape = "\e";
--------------------------------------------------------------------------------
/csharp12/5. Default lambda parameters/Program.cs:
--------------------------------------------------------------------------------
1 | var setVolume = (int value = 0) => $"The volume is set to {value}";
2 |
3 | Console.WriteLine(setVolume());
4 | Console.WriteLine(setVolume(4));
5 |
--------------------------------------------------------------------------------
/csharp12/8. Interceptors/Sender.cs:
--------------------------------------------------------------------------------
1 | namespace _8._Interceptors;
2 |
3 | public class Sender
4 | {
5 | public void SendMessage()
6 | {
7 | Console.WriteLine("Hello everyone!");
8 | }
9 | }
--------------------------------------------------------------------------------
/csharp10/7. Structure Types/Program.cs:
--------------------------------------------------------------------------------
1 | var point = new Point(1,2);
2 | Console.WriteLine(point);
3 |
4 | var point2 = new Point();
5 | Console.WriteLine(point2);
6 |
7 | var point3 = default(Point);
8 | Console.WriteLine(point3);
9 |
--------------------------------------------------------------------------------
/csharp9/2. Records/2. Records.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp5.0
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/csharp11/3. Newlines in string interpolations/Program.cs:
--------------------------------------------------------------------------------
1 | var number1 = 1;
2 | var number2 = 2;
3 | var test = true;
4 |
5 | _ = $"interpolated string with value {(test
6 | ? number1
7 | : number2
8 | )}, and some more text ...";
--------------------------------------------------------------------------------
/csharp12/1. Alias any type/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Dec = decimal; // вместо System.Decimal
3 | using SomethingAbstract = (string, decimal);
4 | using Grade = (string Course, decimal Value);
5 | using unsafe p = decimal*;
6 | Console.ReadLine();
--------------------------------------------------------------------------------
/csharp9/3. TargetTypedObject/3. TargetTypedObject.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp5.0
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/csharp9/4. InitOnlySetters/4. InitOnlySetters.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp5.0
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/csharp9/7. CovariantReturns/7. CovariantReturns.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp5.0
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/csharp10/1. File-Scoped Namespace/Book.cs:
--------------------------------------------------------------------------------
1 | namespace _1._File_Scoped_Namespace;
2 | public class Book
3 | {
4 | public string Title { get; set; }
5 | public Author Author { get; set; }
6 | public Book(string title, Author author) =>
7 | (Title, Author) = (title, author);
8 | }
--------------------------------------------------------------------------------
/csharp10/Csharp10/Program.cs:
--------------------------------------------------------------------------------
1 | Console.WriteLine("Hello World!");
2 |
3 | //namespace HelloWorld
4 | //{
5 | // class Program
6 | // {
7 | // static void Main(string[] args)
8 | // {
9 | // Console.WriteLine("Hello World!");
10 | // }
11 | // }
12 | //}
--------------------------------------------------------------------------------
/csharp10/6. Global Using directive/Author.cs:
--------------------------------------------------------------------------------
1 | namespace _6._Global_Using_directive;
2 | public class Author
3 | {
4 | public string Name { get; set; }
5 | public string LastName { get; set; }
6 | public Author(string name, string lastname) =>
7 | (Name, LastName) = (name, lastname);
8 | }
9 |
--------------------------------------------------------------------------------
/csharp10/2. Extended Property Patterns/Author.cs:
--------------------------------------------------------------------------------
1 | namespace _2._Extended_Property_Patterns;
2 | public class Author
3 | {
4 | public string Name { get; set; }
5 | public string LastName { get; set; }
6 | public Author(string name, string lastname) =>
7 | (Name, LastName) = (name, lastname);
8 | }
9 |
--------------------------------------------------------------------------------
/csharp10/3. Constant Interpolated Strings/Author.cs:
--------------------------------------------------------------------------------
1 | namespace _3._Constant_Interpolated_Strings;
2 | public class Author
3 | {
4 | public string Name { get; set; }
5 | public string LastName { get; set; }
6 | public Author(string name, string lastname) =>
7 | (Name, LastName) = (name, lastname);
8 | }
--------------------------------------------------------------------------------
/csharp12/7. Experimental attribute/Program.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics.CodeAnalysis;
2 |
3 | #pragma warning disable Danger_Identifier
4 | var feature = new DangerFeature();
5 | #pragma warning restore Danger_Identifier
6 |
7 | [Experimental("Danger_Identifier")]
8 | internal class DangerFeature
9 | {
10 | }
--------------------------------------------------------------------------------
/csharp9/1. TopLevelStatement/1. TopLevelStatement.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp5.0
6 | TopLevelStatement
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/csharp10/Csharp10/0. Console Template.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/csharp10/4. Records/4. Records.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 | _4._Records
6 | enable
7 | enable
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/csharp9/6. ExtendedPartialMethods/6. ExtendedPartialMethods.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp5.0
6 | ExtendedPartialMethods
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/csharp12/4. Inline arrays/Program.cs:
--------------------------------------------------------------------------------
1 | var buffer = new Buffer();
2 | for (var i = 0; i < 10; i++)
3 | {
4 | buffer[i] = i;
5 | }
6 |
7 | foreach (var i in buffer)
8 | {
9 | Console.WriteLine(i);
10 | }
11 |
12 | [System.Runtime.CompilerServices.InlineArray(10)]
13 | internal struct Buffer
14 | {
15 | private int _;
16 | }
--------------------------------------------------------------------------------
/csharp10/6. Global Using directive/Store.cs:
--------------------------------------------------------------------------------
1 | namespace _6._Global_Using_directive;
2 | public class Store
3 | {
4 | private readonly IEnumerable Books;
5 | public Store(IEnumerable books) => Books = books;
6 | public IEnumerable GetBooks(Author author) =>
7 | Books.Where(b => b.Author.LastName == author.LastName);
8 | }
--------------------------------------------------------------------------------
/csharp9/5. RelationalAndLogicalPatterns/5. RelationalAndLogicalPatterns.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp5.0
6 | RelationalAndLogicalPatterns
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/csharp12/8. Interceptors/InterceptsLocationAttribute.cs:
--------------------------------------------------------------------------------
1 | namespace System.Runtime.CompilerServices
2 | {
3 | [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
4 | sealed class InterceptsLocationAttribute(
5 | string filePath,
6 | int line,
7 | int column)
8 | : Attribute
9 | {
10 | }
11 | }
--------------------------------------------------------------------------------
/csharp10/1. File-Scoped Namespace/Author.cs:
--------------------------------------------------------------------------------
1 | namespace _1._File_Scoped_Namespace
2 | {
3 | public class Author
4 | {
5 | public string Name { get; set; }
6 | public string LastName { get; set; }
7 | public Author(string name, string lastname) =>
8 | (Name, LastName) = (name, lastname);
9 | }
10 | }
11 |
12 |
--------------------------------------------------------------------------------
/csharp10/4. Records/Circle.cs:
--------------------------------------------------------------------------------
1 | namespace _4._Records;
2 | record Circle
3 | {
4 | public sealed override string ToString()
5 | {
6 | return typeof(Circle).Name;
7 | }
8 | }
9 |
10 | record BigCircle : Circle
11 | {
12 | //public override string ToString()
13 | //{
14 | // return typeof(BigCircle).Name;
15 | //}
16 | }
17 |
--------------------------------------------------------------------------------
/csharp10/1. File-Scoped Namespace/1. File-Scoped Namespace.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 | _1._File_Scoped_Namespace
6 | enable
7 | enable
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/csharp10/6. Global Using directive/6. Global Using directive.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 | _6._Global_Using_directive
6 | enable
7 | enable
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/csharp11/7. Utf8 String Literals/Program.cs:
--------------------------------------------------------------------------------
1 | using System.Text;
2 |
3 | ReadOnlySpan value1 = new byte[12]
4 | {
5 | 72, 101, 108, 108, 111, 32,
6 | 119, 111, 114, 108, 100, 33
7 | };
8 |
9 | ReadOnlySpan value2 = "Hello world!"u8;
10 |
11 | Console.WriteLine(Encoding.UTF8.GetString(value1));
12 | Console.WriteLine(Encoding.UTF8.GetString(value2));
13 |
--------------------------------------------------------------------------------
/csharp10/2. Extended Property Patterns/2. Extended Property Patterns.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 | _2._Extended_Property_Patterns
6 | enable
7 | enable
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/csharp11/4. List patterns/4. List patterns.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net7.0
6 | _4._List_patterns
7 | enable
8 | enable
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/csharp10/5. Deconstruction/5. Deconstruction.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | _5._Deconstruction
7 | enable
8 | enable
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/csharp10/7. Structure Types/7. Structure Types.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | _7._Structure_Types
7 | enable
8 | enable
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/csharp10/3. Constant Interpolated Strings/3. Constant Interpolated Strings.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 | _3._Constant_Interpolated_Strings
6 | enable
7 | enable
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/csharp11/2. Generic Attributes/2. Generic Attributes.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net7.0
6 | _2._Generic_Attributes
7 | enable
8 | enable
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/csharp11/5. RawStringLiterals/5. Raw String Literals.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net7.0
6 | _5._RawStringLiterals
7 | enable
8 | enable
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/csharp11/8. File scoped types/8. File scoped types.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net7.0
6 | _8._File_scoped_types
7 | enable
8 | enable
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/csharp11/1. Auto Default Structs/1. Auto Default Structs.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net7.0
6 | _1._Auto_Default_Structs
7 | enable
8 | enable
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/csharp11/6. Generic math support/6. Generic math support.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net7.0
6 | _6._Generic_math_support
7 | enable
8 | enable
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/csharp11/7. Utf8 String Literals/7. Utf8 String Literals.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net7.0
6 | _7._Utf8_String_Literals
7 | enable
8 | enable
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/csharp11/9. Required Properties/9. Required Properties.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net7.0
6 | _9._Required_Properties
7 | enable
8 | enable
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/csharp12/6. Ref readonly/6. Ref readonly.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net8.0
6 | _6._Ref_readonly
7 | enable
8 | enable
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/csharp10/7. Structure Types/Point.cs:
--------------------------------------------------------------------------------
1 | public struct Point
2 | {
3 | public Point()
4 | {
5 | X = double.NaN;
6 | Y = double.NaN;
7 | }
8 | public Point(double x, double y) =>
9 | (X, Y) = (x, y);
10 |
11 | public double X { get; set; }
12 | public double Y { get; set; }
13 |
14 | public override string ToString() =>
15 | $"X: {X}, Y: {Y}";
16 | }
17 |
--------------------------------------------------------------------------------
/csharp12/4. Inline arrays/4. Inline arrays.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net8.0
6 | _4._Inline_arrays
7 | enable
8 | enable
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/csharp13/1. Params Collections/Program.cs:
--------------------------------------------------------------------------------
1 | ReadOnlySpan text = new(["Hello", "ReadOnlySpan", "World"]);
2 | Printer.PrintElements(text);
3 |
4 | internal static class Printer
5 | {
6 | internal static void PrintElements(params ReadOnlySpan elements)
7 | {
8 | foreach (var element in elements)
9 | {
10 | Console.WriteLine(element);
11 | }
12 | }
13 | }
--------------------------------------------------------------------------------
/csharp10/6. Global Using directive/Book.cs:
--------------------------------------------------------------------------------
1 | namespace _6._Global_Using_directive;
2 | public class Book
3 | {
4 | public string Title { get; set; }
5 | public Author Author { get; set; }
6 | public Book(string title, Author author) =>
7 | (Title, Author) = (title, author);
8 |
9 | public static bool doesHaveDiscount(Book book)
10 | {
11 | return false;
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/csharp13/3. New Lock Object/3. New Lock Object.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net9.0
6 | _3._New_Lock_Object
7 | enable
8 | enable
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/csharp13/8. Allows Ref Struct/8. Allows Ref Struct.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net9.0
6 | _8._Allows_Ref_Struct
7 | enable
8 | enable
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/csharp13/1. Params Collections/1. Params Collections.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net9.0
6 | _1._Params_Collections
7 | enable
8 | enable
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/csharp12/2. Primary constructors/2. Primary constructors.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net8.0
6 | _2._Primary_constructors
7 | enable
8 | enable
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/csharp13/4. New Escape Sequence/4. New Escape Sequence.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net9.0
6 | _4._New_Escape_Sequence
7 | enable
8 | enable
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/csharp12/3. Collection expressions/3. Collection expressions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net8.0
6 | _3._Collection_expressions
7 | enable
8 | enable
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/csharp12/7. Experimental attribute/7. Experimental attribute.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net8.0
6 | _7._Experimental_attribute
7 | enable
8 | enable
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/csharp13/10. More Partial Members/10. More Partial Members.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net9.0
6 | _10._More_Partial_Members
7 | enable
8 | enable
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/csharp13/11. Field Keyword/11. Field Keyword.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net9.0
6 | _11._Field_Keyword
7 | enable
8 | enable
9 | preview
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/csharp13/11. Field Keyword/Program.cs:
--------------------------------------------------------------------------------
1 | Console.WriteLine("Just a hack to make a program compilable");
2 |
3 | // preview must be set in csproj
4 | class TimePeriod
5 | {
6 | public double Hours {
7 | get;
8 | set => field = (value >= 0)
9 | ? value
10 | : throw new ArgumentOutOfRangeException(nameof(value), "The value must not be negative");
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/csharp13/6. Implicit Index Access/6. Implicit Index Access.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net9.0
6 | _6._Implicit_Index_Access
7 | enable
8 | enable
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/csharp13/9. Ref Struct Interfaces/9. Ref Struct Interfaces.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net9.0
6 | _9._Ref_Struct_Interfaces
7 | enable
8 | enable
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/csharp11/3. Newlines in string interpolations/3. Newlines in string interpolations.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net7.0
6 | Newlines_in_string_interpolations
7 | enable
8 | enable
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/csharp12/1. Alias any type/1. Alias any type.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net8.0
6 | _1._Alias_any_type
7 | enable
8 | enable
9 | true
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/csharp12/5. Default lambda parameters/5. Default lambda parameters.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net8.0
6 | _5._Default_lambda_parameters
7 | enable
8 | enable
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/csharp13/5. Method Group Natural Type/5. Method Group Natural Type.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net9.0
6 | _5._Method_Group_Natural_Type
7 | enable
8 | enable
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/csharp11/1. Auto Default Structs/Program.cs:
--------------------------------------------------------------------------------
1 | var data = new Data();
2 | Console.WriteLine(data);
3 | readonly struct Data
4 | {
5 | public decimal Number { get; init; }
6 | public string Text { get; init; }
7 | public DateTime Date { get; init; }
8 |
9 | public Data()
10 | {
11 | Text = string.Empty;
12 | }
13 |
14 | public override string ToString() => $"Number: {Number}, Text: {Text}, Date: {Date}.";
15 | }
16 |
--------------------------------------------------------------------------------
/csharp13/8. Allows Ref Struct/Program.cs:
--------------------------------------------------------------------------------
1 | var notifier = new Notifier>();
2 | var notifier2 = new Notifier();
3 |
4 | public class Notifier where T : allows ref struct
5 | {
6 | // Use T as a ref struct:
7 | public void Notify(scoped T p)
8 | {
9 | // The parameter p must follow ref safety rules
10 | }
11 | }
12 |
13 | public ref struct Data
14 | {
15 | public int Value { get; set; }
16 | }
--------------------------------------------------------------------------------
/csharp13/2. Overload Resolution Priority/2. Overload Resolution Priority.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net9.0
6 | _2._Overload_Resolution_Priority
7 | enable
8 | enable
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/csharp12/8. Interceptors/Hacker.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.CompilerServices;
2 | using _8._Interceptors;
3 |
4 | namespace HackerSpace;
5 |
6 | public static class Hacker
7 | {
8 | [InterceptsLocation(
9 | @"C:\Users\Andrei\source\repos\platinum\csharp12-features\8. Interceptors\Program.cs",
10 | 4,
11 | 8)]
12 | public static void InterceptMessage(this Sender sender)
13 | {
14 | Console.WriteLine("You're hacked");
15 | }
16 | }
--------------------------------------------------------------------------------
/csharp10/5. Deconstruction/Author.cs:
--------------------------------------------------------------------------------
1 | internal class Author
2 | {
3 | public string Name { get; set; }
4 | public string LastName { get; set; }
5 | public Author(string name, string lastname) =>
6 | (Name, LastName) = (name, lastname);
7 |
8 | public void Deconstruct(out string name, out string lastname) =>
9 | (name, lastname) = (Name, LastName);
10 |
11 | public override string ToString() =>
12 | $"{Name} {LastName}";
13 | }
14 |
--------------------------------------------------------------------------------
/csharp12/8. Interceptors/8. Interceptors.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net8.0
6 | _8._Interceptors
7 | enable
8 | enable
9 | $(InterceptorsPreviewNamespaces);HackerSpace
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/csharp13/7. Ref and Unsafe in Async and Iterators/7. Ref and Unsafe in Async and Iterators.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net9.0
6 | _7._Ref_and_Unsafe_in_Async_and_Iterators
7 | enable
8 | enable
9 | true
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/csharp10/2. Extended Property Patterns/Book.cs:
--------------------------------------------------------------------------------
1 | namespace _2._Extended_Property_Patterns;
2 | public class Book
3 | {
4 | public string Title { get; set; }
5 | public Author Author { get; set; }
6 | public Book(string title, Author author) =>
7 | (Title, Author) = (title, author);
8 |
9 | public static bool doesHaveDiscount(Book book) =>
10 | book switch
11 | {
12 | { Author.LastName: "Richter" }
13 | or { Author.LastName: "Price" } => true,
14 | _ => false
15 | };
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/csharp10/3. Constant Interpolated Strings/Book.cs:
--------------------------------------------------------------------------------
1 | namespace _3._Constant_Interpolated_Strings;
2 | public class Book
3 | {
4 | public string Title { get; set; }
5 | public Author Author { get; set; }
6 | public Book(string title, Author author) =>
7 | (Title, Author) = (title, author);
8 |
9 | public string ThankYouMessage()
10 | {
11 | const string message = "Thank you for buying the book!";
12 | const string thankYouMessage = $"{message} Enjoy";
13 | return thankYouMessage;
14 | }
15 | }
--------------------------------------------------------------------------------
/csharp13/9. Ref Struct Interfaces/Program.cs:
--------------------------------------------------------------------------------
1 | var refStruct = new RefStruct { Value = 13 };
2 | Console.WriteLine(refStruct.CheckIfValid());
3 | refStruct.Value *= -1;
4 | Console.WriteLine(refStruct.CheckIfValid());
5 |
6 | ref struct RefStruct : IRefStruct
7 | {
8 | public int Value { get; set; }
9 | public bool CheckIfValid() => Value > 0;
10 |
11 | public int DefaultImplementationMethod() => 1;
12 | }
13 |
14 | interface IRefStruct
15 | {
16 | bool CheckIfValid();
17 |
18 | int DefaultImplementationMethod() => 1;
19 | }
--------------------------------------------------------------------------------
/csharp12/2. Primary constructors/Program.cs:
--------------------------------------------------------------------------------
1 | Article article = new(0, "");
2 | var title = article.Title;
3 | var id = article.Id;
4 |
5 | Console.ReadLine();
6 |
7 | internal class Article(int id, string title) : Item(id)
8 | {
9 | public string Title { get; set; } = title;
10 | private readonly int id = id;
11 |
12 | public int Id => id;
13 |
14 | public Article() : this(0, string.Empty) {}
15 |
16 | public Article(string title, string author) : this(0, title)
17 | {
18 |
19 | }
20 | }
21 |
22 | internal class Item(int id);
--------------------------------------------------------------------------------
/csharp13/6. Implicit Index Access/Program.cs:
--------------------------------------------------------------------------------
1 | var countdown = new TimerRemaining()
2 | {
3 | Buffer =
4 | {
5 | [^1] = 0,
6 | [^2] = 1,
7 | [^3] = 2,
8 | [^4] = 3,
9 | [^5] = 4,
10 | [^6] = 5,
11 | [^7] = 6,
12 | [^8] = 7,
13 | [^9] = 8,
14 | [^10] = 9
15 | }
16 | };
17 |
18 | foreach (var item in countdown.Buffer)
19 | {
20 | Console.WriteLine(item);
21 | }
22 |
23 | public class TimerRemaining
24 | {
25 | public int[] Buffer { get; } = new int[10];
26 | }
27 |
--------------------------------------------------------------------------------
/csharp11/2. Generic Attributes/Program.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | namespace _2._Generic_Attributes
4 | {
5 | // before
6 | public class TypeAttribute : Attribute
7 | {
8 | public Type ParamType { get; }
9 | public TypeAttribute(Type t) => ParamType = t;
10 | }
11 |
12 | public class GenericType
13 | {
14 | //[TypeAttribute(typeof(string))]
15 | [GenericAttribute