Lozano23 [ Pretorianin ]
'() =>' w C# - a w VB?
Mam taki kod:
DataTable roleTable = ADDContext.Current.Cache.GetItem(
ADDCache.GetBoardCacheKey(Constants.Cache.roleTable),
ADDContext.Current.BoardSettings.CacheTimeout,
() => DB.roleList(ADDContext.Current.PageBoardID));
Jaki jest odpowiednik "() =>" w VB?
Co to w ogóle jest "() =>" ?
Z góry dziękuję.
legrooch [ MPO Squad Member ]
Nie ma czegoś takiego w C#.
Wrzuć kod, który chcesz skonwertować.
Lozano23 [ Pretorianin ]
Jak nie ma, jak jest :D
Kod funkcji GetItem:
Public Function GetItem(Of T As Class)(ByVal key As String, ByVal expireMilliseconds As Double, ByVal priority As CacheItemPriority, ByVal getValue As Func(Of T)) As T
...
End Function
Wygooglowałem, że "() =>" to operator wyrażeń Lambda ;)
legrooch [ MPO Squad Member ]
Twój kod wygląda dokładnie tak:
DataTable roleTable = ADDContext.Current.Cache.GetItem(ADDCache.GetBoardCacheKeyConstants.Cache.roleTable), ADDContext.Current.BoardSettings.CacheTimeout, () => DB.roleList(ADDContext.Current.PageBoardID));
Pierwsze pytanei - co robi tam przecinek po cachetimeout?
Opierając się o kod funckji getItem powinno być
.GetItem(myClass)("key",1000,CacheItemPriority.High, getValue(myClass))
W Twoim przypadku nie ma żadnego powiązania z tym, co napisałeś :)
Spróbuj użyć tego:
I mam prośbę - wrzuć poprawnie ten kawałek kodu :)