【发布时间】:2010-11-29 20:15:38
【问题描述】:
有代码:
Private Sub InsertItemInCache(Of T)(ByVal item As CachedItem(Of T), ByVal dependency As AggregateCacheDependency, _
ByVal key As String, ByVal updateCallBack As CacheItemUpdateCallback)
CacheItemUpdateCallback 的签名是:
Sub CacheItemUpdateCallback(ByVal key As String, ByVal reason As CacheItemUpdateReason, _
ByRef expensiveObject As Object, ByRef dependency As CacheDependency, ByRef absoluteExpiration As Date, _
ByRef slidingExpiration As TimeSpan)
我想为此使用lamba 表达式调用InsertItemInCache 函数。 此代码未编译:
InsertItemInCache(cachedItem, dependency, key, Function(k, r, e, d, a, s) CacheItemUpdateCallback(k, r, e, d, a, s))
它说表达式不会产生值
如果我将 Sub CacheItemUpdateCallback 更改为 Function CacheItemUpdateCallback 它也没有被编译并且说 嵌套函数没有与委托相同的签名 'Delegate Sub CacheItemUpdateCallback(key As String, reason As System.Web.Caching.CacheItemUpdateReason, ByRef luckyObject As Object, ByRef dependency As System.Web .Caching.CacheDependency, ByRef absoluteExpiration As Date, ByRef slipExpiration As System.TimeSpan)'
谁能帮我通过 lambda 表达式调用这个方法?我想将来使用闭包并以这种方式调用此函数:
InsertItemInCache(cachedItem, dependency, key, Function(k, r, e, d, a, s) CacheItemUpdateCallbackNew(k, r, e, d, a, s, additionalParameter1, additionalParameter2, additionalParameter3))
【问题讨论】:
-
这能回答你的问题吗? VB lambda expression for sub delegate
标签: vb.net