Your SlideShare is downloading. ×
  • Like
Expression 的介紹及應用
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Expression 的介紹及應用

  • 202 views
Published

 

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
202
On SlideShare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
1
Comments
0
Likes
0

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. Expression 的介紹及應用 2014/03/27 Bryan Lin
  • 2. Agenda • 什麼是 Expression • Expression 的種類 • Expression 的應用
  • 3. 什麼是 Expression • 在我們的程式碼裡面,所有的程式碼都可以使用 Expression 來組合 • 最常見的例子就是 Lambda Expression  Expression<Func<int, bool>> lambda = num => num < 5;
  • 4. Expression 的種類
  • 5. Expression 的種類 • 其他種類請參考 MSDN 上面的說明: http://msdn.microsoft.com/enus/library/system.linq.expressions.asp x
  • 6. Expression 的應用 • 範例1:組合出 x = 1 的 Expression (x 的型別為 Int32) • 提示: 使用 Expression.Parameter 使用 Expression.Constant 使用 Expression.Equals
  • 7. Expression 的應用 • 解答: • Expression left = Expression.Parameter(typeof(Int32), “x”); • Expression right = Expression.Constant(1); • Expression expression = Expression.Assign(left, right); • // x = 1
  • 8. Expression 的應用 • 範例2:製作一個 Extension Method,如下所示:
  • 9. Expression 的應用 • 解答:
  • 10. FAQ