Your SlideShare is downloading. ×
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
C# 4.0 - Cairo Code Camp 2010
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

C# 4.0 - Cairo Code Camp 2010

913

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
913
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
13
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Productivity in C# 4.0
    1
  • 2. Mohammad Tayseer
    2
  • 3. Productivity
    3
  • 4. Productivity=Value
    4
  • 5. 5
    Partial Classes
    Object-Oriented Programming
    Generics
    C#
    Anonymous Types
    Expression Trees
    Lambda Expressions
    Extension Methods
    Nullable
    LINQ
    Delegates
  • 6. C# 4.0
    6
  • 7. Dynamic capabilities
    Optional and named arguments
    Co-variant and contra-variant
    Better COM interoperability
    7
  • 8. Dynamic?
    8
  • 9. int x = …;x.GetType(); // Safex.SomeMethod(); // Compilation // errordynamic d = x;d.GetType(); // Safed.SomeMethod(); // Dispatched // at runtime
    9
  • 10. x.SomeMethod()
    x has SomeMethod
    x.TryInvokeMember(“SomeMethod”, …)
    10
  • 11. interface IDynamicMetaObjectProvider
    {
    boolTryGetMember(…);
    boolTrySetMember(…);
    boolTryDeleteMember(…);
     
    boolTryInvoke(…);
    boolTryInvokeMember(…);
    boolTryCreateInstance(…);
     
    boolTryGetIndex(…);
    boolTrySetIndex();
    boolTryDeleteIndex(…);
    … 
    }
    11
  • 12. 12
    IronPython
    IronRuby
    C#
    VB.NET
    Others…
    Dynamic Language Runtime
    PythonBinder
    COMBinder
    ObjectBinder
  • 13. C# 4.0 Dynamic
    ?
    13
  • 14. C# 4.0
    Static
    Optional dynamic
    14
  • 15. When?
    15
  • 16. Productivity
    16
  • 17. int x = …;dynamic d = x;d.SomeMethod(); // Runtime // error
    17
  • 18.
    18
  • 19. ((MyCompany.MyClient.MyProject.Workflow.Activities.SqlSelect)this.GetActivityByName(“SqlSelect1”)).RowsAffected > 1
    19
  • 20. ((MyCompany.MyClient.MyProject.Workflow.Activities.SqlSelect)this.GetActivityByName(“SqlSelect1”)).RowsAffected > 1
    20
  • 21. ((MyCompany.MyClient.MyProject.Workflow.Activities.SqlSelect)this.GetActivityByName(“SqlSelect1”)).RowsAffected > 1
    21
  • 22. This is too complex
    22
  • 23. this.SqlSelect1.RowsAffected > 1
    23
    Runtime Lookup
    Recursive
  • 24. ((MyCompany.MyClient.MyProject.Workflow.Activities.SqlSelect)this.GetActivityByName(“SqlSelect1”)).RowsAffected > 1this.SqlSelect1.RowsAffected > 1
    24
  • 25. dynamic x = …;
    x.GetType();
    x.Property1 = x.Property2;
    x[“1”] = x[“value 2”];
    x(1, 2, 3)
    x++;
    x.ExtensionMethod() // Runtime error
    25
  • 26. Dynamic DispatchDemo
    26
  • 27. Named & optional parameters
    27
  • 28. chart.ChartWizard(
    range.CurrentRegion,
    MissingValue,
    MissingValue,
    MissingValue,
    MissingValue,
    MissingValue,
    MissingValue,
    "Memory Usage in " + Environment.MachineName,
    MissingValue,
    MissingValue,
    MissingValue);
    28
  • 29.
    29
  • 30. chart.ChartWizard(
    range.CurrentRegion, // Source
    MissingValue, // Gallery
    MissingValue, // Format
    MissingValue, // PlotBy
    MissingValue, // CategoryLabels
    MissingValue, // SeriesLabels
    MissingValue, // HasLegend
    // Title
    "Memory Usage in " + Environment.MachineName,
    MissingValue, // CategoryTitle
    MissingValue, // ValueTitle
    MissingValue); // ExtraTitle
    30
  • 31. Strongly-typednamed parameters
    31
  • 32. chart.ChartWizard(
    Source: range.CurrentRegion,
    Gallery: MissingValue,
    Format: MissingValue,
    PlotBy: MissingValue,
    CategoryLabels: MissingValue,
    SeriesLabels: MissingValue,
    HasLegend: MissingValue,
    Title: "Memory Usage in " + Environment.MachineName,
    CategoryTitle: MissingValue,
    ValueTitle: MissingValue,
    ExtraTitle: MissingValue);
    32
  • 33. chart.ChartWizard(
    Source: range.CurrentRegion,
    Gallery: MissingValue,
    Format: MissingValue,
    PlotBy: MissingValue,
    CategoryLabels: MissingValue,
    SeriesLabels: MissingValue,
    HasLegend: MissingValue,
    Title: "Memory Usage in " + Environment.MachineName,
    CategoryTitle: MissingValue,
    ValueTitle: MissingValue,
    ExtraTitle: MissingValue);
    33
  • 34.
    34
  • 35. Optional parameters
    35
  • 36. chart.ChartWizard(
    Source: range.CurrentRegion,
    Gallery: MissingValue,
    Format: MissingValue,
    PlotBy: MissingValue,
    CategoryLabels: MissingValue,
    SeriesLabels: MissingValue,
    HasLegend: MissingValue,
    Title: "Memory Usage in " + Environment.MachineName,
    CategoryTitle: MissingValue,
    ValueTitle: MissingValue,
    ExtraTitle: MissingValue);
    36
  • 37. chart.ChartWizard(
    Source: range.CurrentRegion,
    Title: "Memory Usage in " + Environment.MachineName);
    37
  • 38. public void ChartWizard(
    Source = null,
    Gallery = null,
    Format = null,
    PlotBy = null,
    CategoryLabels = null,
    SeriesLabels = null,
    HasLegend = null,
    Title = “”,
    CategoryTitle = null,
    ValueTitle = null,
    ExtraTitle = null)
    38
  • 39. Co-variance & Contra-variance
    39
  • 40. Back to Basics
    40
  • 41. Lion is-a AnimalCamel is-a Animal
    41
  • 42. public static string CleanAnimal(Animal a)
    {

    }
    CleanAnimal(camel);
    CleanAnimal(lion);
    42
  • 43. ThusStack<Lion>is-aStack<Animal>
    43
  • 44. No
    44
  • 45. public static string CleanAll(Stack<Animal> animals)
    { … }
    Stack<Lion> lions =
    { … };
    CleanAll(lions);
    45
  • 46. public static string CleanAll(Stack<Animal> animals)
    {
    animals.Push(new Camel());

    }
    46
  • 47. Stack<Lion> is-notStack<Animal>
    47
  • 48. IEnumerable<Lion> should-beIEnumerable<Animal>
    48
  • 49. IEnumerable<Lion>,IEnumerator<Lion> are read-only
    49
  • 50. Only in C# 4
    50
  • 51. interface IEnumerator<out T>
    // T only in output position
    {
    T Current { get; }
    }
    51
  • 52. interface IEnumerable<out T>
    {
    IEnumerator<T> GetEnumerator();
    }
    52
  • 53. Co-variance
    53
  • 54. Now Contra-variance
    54
  • 55. interface IPushable<in T>
    {
    void Push(T element);
    }
    55
  • 56. IPushable<Animal>is-aIPushable<Lion>
    56
  • 57. IPushable<Lion> lions = animals;
    lions.Push(new Lion());
    IPushable<Camel> camels = animals;
    camels.Push(new Camel());
    57
  • 58. Limitations
    58
  • 59. Interfaces
    Delegates
    Reference types
    59
  • 60. Co-variance & Contra-varianceDemo
    60
  • 61. BetterCOMInteroperability
    61
  • 62. Dynamic
    Optional & named params
    No PIA
    Omitting ref
    62
  • 63. Demos
    63
  • 64. ?
    64
  • 65. twitter.com/m_tayseerhttp://spellcoder.com/blogs/tayseerm_tayseer82@yahoo.com
    65

×