.NET and .NET Core 9. Towards Higher Order Pan Wuming 2017
Topics Towards Higher Order: Expressiveness Towards Higher Order: Enhanced Dynamics Towards Higher Order: Compiling As Services Covariance and Contravariance Three new languages: C#, IL and F# Evolving from OO Paradigm Everything is object Members for Abstraction Accessibility for Encapsulation Inheritance and Polymorphism Solving name confliction and multi-inheritance Towards higher order: Expressiveness Delegate Lambda Expression Generic Attribute LINQ Compiler API Effective coding References: Common Type System(MSDN) .NET Framework Class Library Overview (MSDN) Inheritance (C# Programming Guide) (MSDN) Polymorphism (C# Programming Guide) (MSDN)
3. Towards higher order: Expressiveness Iterators Lambda Expression Generic LINQ Extension method Effective Coding
Iterators An iterator method or get accessor performs a custom iteration over a collection. An iterator method uses the yield return (C#) statement to return each element one at a time. When a yield return statement is reached, the current location in code is remembered. Execution is restarted from that location the next time the iterator function is called.
Lambda Expression
Effective coding: Examples Indexers Foreach loop Partial Class Nullable Type Automatic implementation of Property Array Initialization Implicitly Typed Named and Optional Arguments Int? i=5; Instances of the System.Nullable<T> struct public string FirstName { get; set; } = "Jane"; int[] Numbers = { 0, 1, 2, 3, 4 }; var i = 1; var hw = "Hello World!";
5. Towards Higher Order: Enhanced Dynamics Type Class and Reflection Dynamic Language Runtime Dynamic languages can identify the type of an object at run time The ability to use a rapid feedback loop (REPL, or read-evaluate-print loop). Support for both top-down development and more traditional bottom-up development Easier refactoring and code modifications Dynamic languages make excellent scripting languages
Towards Higher Order: Compiling As Services Compiler API Scripting
See you next class Layperson Professional