不包含的定义,也没有找到接受类型为第一个参数的扩展方法 [英] Does not contain a definition for and no extension method accepting a first argument of type could be found

查看:157
本文介绍了不包含的定义,也没有找到接受类型为第一个参数的扩展方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经研究了一些解决该问题的方法,但是它们似乎与我所遇到的解决方案并不相同.

I've looked around at some of the solutions to this problem but they don't seem to be the same as what I'm experiencing.

我要调用的方法:

namespace BetfairAPI
{
    public class CBetfairAPI
    {
        public ArrayList placeBets(ArrayList betList, double stakeSize)
        {
            // code to betList maniplulate

            return betList;
        }
    }
}

我从中调用的方法:

namespace Bot
{
    public partial class Form1 : Form
    {
            private void makeBets(MarketSummary mkt, double odds, double stakeAmt)
            {
                ArrayList betList = new ArrayList();

                // code to build "betList"

                ArrayList bets = MyBetfair.placeBets(betList, stakeAmt);

            }
        }
    }
}

我收到的错误:

错误1'BetfairAPI.CBetfairAPI'不包含
的定义 'placeBets'并且没有扩展方法'placeBets'接受第一个 可以找到类型为'BetfairAPI.CBetfairAPI'的参数(您是 缺少using指令或程序集引用?)

Error 1 'BetfairAPI.CBetfairAPI' does not contain a definition for
'placeBets' and no extension method 'placeBets' accepting a first argument of type 'BetfairAPI.CBetfairAPI' could be found (are you missing a using directive or an assembly reference?)

在CBetfairAPI类中使用任何其他方法都没有问题.如果我执行"CBetfairAPI",则在Visual Studio的下拉菜单中不会显示placeBets(). (所有其他方法和字段都可以).

I have no problem using any other methods in the CBetfairAPI class. placeBets() doesn't show up in the drop down menu in Visual studio if I do 'CBetfairAPI.' (all the other methods and fields do).

感谢您的帮助.

推荐答案

placeBets(betList, stakeAmt) instance 方法,而不是 static 方法.您需要先创建CBetfairAPI的实例:

placeBets(betList, stakeAmt) is an instance method not a static method. You need to create an instance of CBetfairAPI first:

MyBetfair api = new MyBetfair();
ArrayList bets = api.placeBets(betList, stakeAmt);

这篇关于不包含的定义,也没有找到接受类型为第一个参数的扩展方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆