首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

Expression.Call的有关问题

2013-08-09 
Expression.Call的问题本帖最后由 z1101385391 于 2013-07-16 12:06:17 编辑public IEnumeratorTEntity

Expression.Call的问题
本帖最后由 z1101385391 于 2013-07-16 12:06:17 编辑


public IEnumerator<TEntity> GetEnumerator()
        {
            return Execute<IEnumerator<TEntity>>(Expression.Call(Expression,
(MethodInfo)MethodBase.GetCurrentMethod()));
        }


像上面这么写会报这个错误
方法 System.Collections.Generic.IEnumerator`1[TEntity] GetEnumerator() 包含泛型参数
改成这样

public IEnumerator<TEntity> GetEnumerator()
        {
            return Execute<IEnumerator<TEntity>>(Expression.Call(Expression, 
((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TEntity))));
        }


会报这个错误
System.Collections.Generic.IEnumerator`1[TEntity] GetEnumerator() 不是 GenericMethodDefinition。只能对 MethodBase.IsGenericMethodDefinition 为 True 的方法调用 MakeGenericMethod。

要怎么写才是正确的?
[解决办法]
Execute方法在哪里定义的。

热点排行