async static Task Main(string[] args) { Console.WriteLine("\n=== IndicesAndRanges ==="); IndicesAndRanges.Demo(); Console.WriteLine("\n=== SwitchExpressions ==="); SwitchExpressions.Demo(); Console.WriteLine("\n=== PatternMatching ==="); PatternMatching.Demo(); Console.WriteLine("\n=== StaticLocalFunctions ==="); StaticLocalFunctions.Demo(); Console.WriteLine("\n=== UsingDeclarations ==="); UsingDeclarations.Demo(); Console.WriteLine("\n=== AsyncStreams ==="); await AsyncStreams.Demo(); Console.WriteLine("\n=== TargetTypedNew ==="); TargetTypedNew.Demo(); Console.WriteLine("\n=== NullCoallescingAssignment ==="); NullCoallescingAssignment.Demo(); Console.WriteLine("\n=== DefaultInterfaceMethods ==="); DefaultInterfaceMethods.Demo(); Console.WriteLine("\n=== DisposableRefStruct ==="); DisposableRefStruct.Demo(); Console.WriteLine("\n=== UnmanagedConstructedTypes ==="); UnmanagedConstructedTypes.Demo(); }
static void Main() { //0. Attributes on Properties AttributesOnProperties.Run(); //1. Readonly members ReadonlyMembers.Run(); //2. Default interface methods DefaultInterfaceMethods.Run(); //3. Patterns matching PatternMatching.Run(); //4. Using Declarations UsingDeclarations.Run(); //5. Static Local Functions StaticLocalFunctions.Run(); //6. Disposable ref structs DisposableRefStructs.Run(); //7. Nullable Reference Types NullableReferenceTypes.Run(); //8. Asynchronous streams AsynchronousStreams.Run(); //9. Asynchronous disposable AsynchronousDisposable.Run(); //10. Indeces And Ranges IndecesAndRanges.Run(); //11. Null-coalescing assignment NullCoalescingAssignment.Run(); //12. Nested Stackalloc NestedStackalloc.Run(); //13. Enhancement of interpolated verbatim strings InterpolatedVerbatimStringsEnhancement.Run(); }
public eight() { // https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-8 // readonly members var what = new ReadonlyMembers(); // default interface methods var aCoolCar = new MyCar(); // cannot do, not exposed //var output = aCoolCar.MakeNoise(); // pattern improvements var patterns = new MorePatterns(); // using declarations var useDeclarations = new UsingDeclarations(); // static local functions var staticLocal = new StaticLocal(); // disposable ref structs // don't care // nullable reference types var argh = new NullableRefs(); // asynchronous streams // don't care, but probably will one day // indices and ranges var indiciesAndRanges = new IndiciesAndRanges(); // null coalescing assignment var pantsChecking = new NullCoalescingAssignment(); // unmanaged constructed types // why? // stackalloc in nested expressions // what }
static async Task Main(string[] args) { var ascData = Enumerable.Range(1, 7).ToArray(); var asc = new AsyncStreamConsumer <int>(ascData, TimeSpan.FromSeconds(.5)); //await asc.ConsumeStream(); var iar = new IndicesAndRanges(); //iar.PrintExamples(); var rom = new ReadonlyMembers(1, 7, 12); //Console.WriteLine(rom.D); //Console.WriteLine(rom.Roots()); var dim1 = new DefaultInterfaceMethods1(Enumerable.Range(1, 100).ToList()); var idim1 = (IDefaultInterfaceMethods1)dim1; // Call Count in DefaultInterfaceMethods (!) //Console.WriteLine(idim1.Count); //Console.WriteLine(dim1.Count); var dim2 = new DefaultInterfaceMethods2(Enumerable.Range(1, 100).ToList()); var idim2 = (IDefaultInterfaceMethods1)dim2; // It is not possible call Count directly //Console.WriteLine(idim2.Count); //Console.WriteLine(((IDefaultInterfaceMethods)dim2).Count); var pp1 = new PositionalPatterns <char>("jedna dve"); (var head1, var tail1) = pp1; //Console.WriteLine(head1); //Console.WriteLine(string.Join(string.Empty, tail1)); var pp2 = new PositionalPatterns <char>(""); (var head2, var tail2) = pp2; //Console.WriteLine(head2); //Console.WriteLine(string.Join(string.Empty, tail2)); var nol = await UsingDeclarations.nol("jedna" + Environment.NewLine + "dve honza" + Environment.NewLine + "jde"); //Console.WriteLine(nol); //var p0 = StaticLocalFunctions.FibNum(0); //var p1 = StaticLocalFunctions.FibNum(1); //var p2 = StaticLocalFunctions.FibNum(2); //var p7 = StaticLocalFunctions.FibNum(6); //Console.WriteLine(p0); //Console.WriteLine(p1); //Console.WriteLine(p2); //Console.WriteLine(p7); //Console.WriteLine(string.Join(' ', StaticLocalFunctions.FibSeq(20))); //RefStructDispose(); //var nca1 = new NullcoalescingAssignment(); //var def = nca1.Add(default); //var val = nca1.Add("value"); //Console.WriteLine(def); //Console.WriteLine(val); //Console.WriteLine(string.Join(',', nca1.Data)); //Console.WriteLine(); //var nca2 = new NullcoalescingAssignment(nca1.Data); //nca2.Add("Data"); //Console.WriteLine(string.Join(',', nca2.Data)); UnmanagedConstructedTypes.DisplaySize(); Console.ReadLine(); }