Advanced features in C# presents about Attributes; Delegates & Events; Anonymous Types & Dynamic Type; Extension Methods; Lambda Expressions; Reflection; Preprocessor Directives; Garbage Collection; Q&A of the Advanced features in C#. | Advanced features in C# 1 1 Agenda Attributes Delegates & Events Anonymous Types & Dynamic Type Extension Methods Lambda Expressions Reflection Preprocessor Directives Garbage Collection Q&A 2 Agenda Attributes Delegates & Events Anonymous Types & Dynamic Type Extension Methods Lambda Expressions Reflection Preprocessor Directives Garbage Collection Q&A 3 Attributes It’s often necessary to associate information (metadata) with types and members, . Documentation URL for a class Transaction context for a method XML persistence mapping COM ProgID for a class Attributes allow you to decorate a code element Assembly, module, type, member, return value and parameter) with additional information 4 PHUOCNT1: Giống khái niệm Annotation của Java 4 Attributes 5 Create new DisplayName attribute Apply DisplayName to add metadata for enum Trong ví dụ là dùng attribute để hiện thị text cho một loại enum 5 Attributes Attributes are superior to the alternatives Modifying the source language Using . | Advanced features in C# 1 1 Agenda Attributes Delegates & Events Anonymous Types & Dynamic Type Extension Methods Lambda Expressions Reflection Preprocessor Directives Garbage Collection Q&A 2 Agenda Attributes Delegates & Events Anonymous Types & Dynamic Type Extension Methods Lambda Expressions Reflection Preprocessor Directives Garbage Collection Q&A 3 Attributes It’s often necessary to associate information (metadata) with types and members, . Documentation URL for a class Transaction context for a method XML persistence mapping COM ProgID for a class Attributes allow you to decorate a code element Assembly, module, type, member, return value and parameter) with additional information 4 PHUOCNT1: Giống khái niệm Annotation của Java 4 Attributes 5 Create new DisplayName attribute Apply DisplayName to add metadata for enum Trong ví dụ là dùng attribute để hiện thị text cho một loại enum 5 Attributes Attributes are superior to the alternatives Modifying the source language Using external files, ., .IDL, .DEF Attributes are extensible Attributes allow to you add information not supported by C# itself Not limited to predefined information Built into the .NET Framework, so they work across all .NET languages Stored in assembly metadata 6 6 Attributes Attribute Name Description Browsable Should a property or event be displayed in the property window Serializable Allows a class or struct to be serialized Obsolete Compiler will complain if target is used ProgId COM Prog ID Transaction Transactional characteristics of a class 7 Some predefined .NET Framework attributes 7 Agenda Attributes Delegates & Events Anonymous Types & Dynamic Type Extension Methods Lambda Expressions Reflection Preprocessor Directives Garbage Collection Q&A 8 Delegates A delegate is a reference type that defines a method signature A delegate instance holds one or more methods Essentially an “object-oriented function pointer” Methods can be static or non-static Methods can return a value .