• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
15   anonymous methods, partial types and nullable types

15 anonymous methods, partial types and nullable types






Total Views
Views on SlideShare
Embed Views



0 Embeds 0

No embeds


Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

    15   anonymous methods, partial types and nullable types 15 anonymous methods, partial types and nullable types Presentation Transcript

    • Anonymous Methods,Partial Types and Nullable Types Programming in C# tnngo2@gmail.com
    • Anonymous Methods
    • Anonymous Methods an inline nameless block of code.
    • Features accept parameters ref, out, generic type cannot include jump statements such as goto and break
    • Benefits No separate named methods Reduced number of methods Better understanding
    • Implementation Anonymous methods are not given any return type Anonymous methods are not prefixed with access modifiers https://gist.github.com/2586919
    • Referencing multiple anonymous methods https://gist.github.com/2586945
    • Passing parameters https://gist.github.com/2586982
    • Partial Types
    • Partial Types indicates that other parts of the class, struct or interface can be defined in different files or namespaces. All the parts will be formed to the final type at compile time.
    • Partial type? working on large projects, multiple programmers work on one class. working with automatically generated source, code can be added to the class without modifying the source file.
    • Implementation Each of the partial parts of the code must have the same access modifier if a part of code is declared as abstract and others are declared as public => the entire code is considered abstract. Same as sealed class. https://gist.github.com/2592542
    • Implementation (cont.) Partial Class https://gist.github.com/2592720
    • Question
    • Question
    • Nullable Types
    • Nullable types? Before C# 2.0, only reference type could be null
    • Nullable types Null values can be defined for the value types. instance of the System.Nullable<T> struct.
    • Implementation Nullable types have two properties: HasValue Value can also use the == and != operators if (x != null) y = x; https://gist.github.com/2592834
    • Implementation (cont.) Nullable types in Expression https://gist.github.com/2592857
    • ?? Operator assign a nullable type to a non-nullable type. https://gist.github.com/2592875