本週學習心得分享
Vic Chih
2015-11-20
本週主題
• C# MSDN
– Main() and Command-Line Arguments
– Properties
– Override and new
• 使用LINQPad
– Generics
– LINQ
Command-Line Arguments
• 透過命令列引數 傳遞參數值給程式
• C# command line compiler (csc 來編譯)
• f <int>
Properties (get;set;)
• 類似建立 方法 達到設定、取得private Variable
• Set 可以建立篩選規則避免不必要的錯誤
• 若把set刪除,可以讓string app變為唯讀
Override and new
• 右邊兩種程式分別實作new 跟
override
• new 的定義是隱藏父類別的method
• Override 的定義是改寫父類別的
method
• 但使用new的method來實作時的結
果卻出現move by:Run
• 而override的method來實作時的結
果則出現我們預期的結果move by:
Swim
Generics Collection
• Generics 可以在宣告類別、方法結構時可以引用各種型別
• 再搭配LINQ使用起來較array list更具功能性
LINQ
• Language-Integrated Query
– 具備Query的能力
– 目的:透過一致的方法,存取各種資料來源
• Query syntax & Fluent syntax(Lambda Expressions)
• LINQ and Deferred Execution
LINQ - Query syntax
LINQ - Fluent syntax
LINQ and Deferred Execution
LINQ, execution of a query is usually deferred until the moment when
you actually request the data
LINQ and Deferred Execution
• Deferred execution is a two edged sword:
• Composable queries and deferred execution work together to
make LINQ an unusual rich query language. If you properly
understand these features of LINQ you will be able to write less
code, that executes faster, in order to accomplish more.
• As you have seen, if we don’t properly understand deferred
execution then we can end up with a sheepish grin on our face.
Queries might not execute when we expect them to, and we might
report erroneous results to the user.
Reference
• http://blogs.msdn.com/b/charlie/archive/2007/12/09/deferred-
execution.aspx
Thank you for your listening

Vic weekly learning_20151120

  • 1.
  • 2.
    本週主題 • C# MSDN –Main() and Command-Line Arguments – Properties – Override and new • 使用LINQPad – Generics – LINQ
  • 3.
    Command-Line Arguments • 透過命令列引數傳遞參數值給程式 • C# command line compiler (csc 來編譯) • f <int>
  • 4.
    Properties (get;set;) • 類似建立方法 達到設定、取得private Variable • Set 可以建立篩選規則避免不必要的錯誤 • 若把set刪除,可以讓string app變為唯讀
  • 5.
    Override and new •右邊兩種程式分別實作new 跟 override • new 的定義是隱藏父類別的method • Override 的定義是改寫父類別的 method • 但使用new的method來實作時的結 果卻出現move by:Run • 而override的method來實作時的結 果則出現我們預期的結果move by: Swim
  • 6.
    Generics Collection • Generics可以在宣告類別、方法結構時可以引用各種型別 • 再搭配LINQ使用起來較array list更具功能性
  • 7.
    LINQ • Language-Integrated Query –具備Query的能力 – 目的:透過一致的方法,存取各種資料來源 • Query syntax & Fluent syntax(Lambda Expressions) • LINQ and Deferred Execution
  • 8.
  • 9.
  • 10.
    LINQ and DeferredExecution LINQ, execution of a query is usually deferred until the moment when you actually request the data
  • 11.
    LINQ and DeferredExecution • Deferred execution is a two edged sword: • Composable queries and deferred execution work together to make LINQ an unusual rich query language. If you properly understand these features of LINQ you will be able to write less code, that executes faster, in order to accomplish more. • As you have seen, if we don’t properly understand deferred execution then we can end up with a sheepish grin on our face. Queries might not execute when we expect them to, and we might report erroneous results to the user.
  • 12.
  • 13.
    Thank you foryour listening