Pages - Menu

2016年9月7日 星期三

Linq使用Find找不到 Contains 的解決方式

最近使用Dapper,越用越順手,但今天突然發現一個問題。
以前用 List 可以使用 Find 然後 用 Contains 去尋找相等的字串
(e.g.
Dim _par As savePar = linePar.Find(Function(p) p.LineNo.Contains(RbChecked.Text))
)
但今天怎麼用都用不出來,都是找不到Contains 的關鍵字
後來發現,我在宣告的時候

Private _message As String

Property message
    Get
        Return _message
    End Get
    Set(value)
        _message = value
    End Set
End Property




沒有宣告類型,所以該物件是 Object 型態。
後來改成

Property message As String
    Get
        Return _message
    End Get
    Set(value As String)
        _message = value
    End Set
End Property


就有了。
此時不得不說,用C#多爽快阿,
message {get;set}   搞定,還不會發生這種錯誤。

沒有留言:

張貼留言