求C#大神指点。重写抽象方法一直提示没有找到合适的方法重写。基类是有该方法的,拼写也没有错,我快吐血了
基类:public abstract class SolrSearcher : Searcher { protected SolrSearcher(); protected abstract string SolrCoreName { get; } protected virtual QueryOptions BuildQueryOptions(SearchCondition condition); protected abstract Result TransformSolrQueryResult(SolrQueryResults solrQueryResult, SearchCondition condition); }实现类方法: new protected QueryOptions BuildQueryOptions(SearchCondition condition){//此方法硬要说返回值和基类不同,不得已才用了new}protected override WeaponrySearchResult TransformSolrQueryResult(SolrQueryResults solrQueryResult, SearchCondition condition) {//省略掉了}错误 3 “DefenderKingdom.Service.WeaponrySearcher.BuildQueryOptions(DK.Utility.DataAccess.SearchEngine.SearchCondition)”: 返回类型必须是“SolrNet.Commands.Parameters.QueryOptions”才能与重写成员“DK.Utility.DataAccess.SearchEngine.Solr.SolrSearcher.BuildQueryOptions(DK.Utility.DataAccess.SearchEngine.SearchCondition)”匹配 C:\Users\duguk\Desktop\DefenderKingdom\DefenderKingdom.Service\WeaponrySearcher.cs 20 41 DefenderKingdom.Service错误 4 “DefenderKingdom.Service.WeaponrySearcher.TransformSolrQueryResult(SolrNet.SolrQueryResults, DK.Utility.DataAccess.SearchEngine.SearchCondition)”: 没有找到适合的方法来重写 C:\Users\duguk\Desktop\DefenderKingdom\DefenderKingdom.Service\WeaponrySearcher.cs 34 49 DefenderKingdom.Service我简直醉了
慕哥9229398
浏览 1322回答 3
3回答
-
紫衣仙女
亲,编译时都给出提示了,返回类型与基类不符啊。
protected QueryOptions BuildQueryOptions(SearchCondition condition)
改成
protected SolrNet.Commands.Parameters.QueryOptions BuildQueryOptions(SearchCondition condition)
-
手掌心
抽象方法和虚拟方法都用override重写
-
冉冉说
终于解决了,其实是dll版本的问题
打开App,查看更多内容