GRY-Online.pl --> Archiwum Forum

'() =>' w C# - a w VB?

19.05.2010
13:51
[1]

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ę.

19.05.2010
14:29
[2]

legrooch [ MPO Squad Member ]

Nie ma czegoś takiego w C#.
Wrzuć kod, który chcesz skonwertować.

19.05.2010
14:44
[3]

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 ;)

19.05.2010
14:56
[4]

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 :)

© 2000-2024 GRY-OnLine S.A.