Does not contain a definition for and no extension

2019-04-26 04:45发布

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.

Method that I'm trying to call:

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

            return betList;
        }
    }
}

Method that I'm calling from:

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

            }
        }
    }
}

Error that I'm receiving:

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

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

Thanks for your help.

标签: c# betfair
3条回答
地球回转人心会变
2楼-- · 2019-04-26 05:31

There are two cases in which this error is raised.

  1. You didn't declare the variable which is used
  2. You didn't create the instances of the class
查看更多
Viruses.
3楼-- · 2019-04-26 05:35

Declare an instance of the CBetfairAPI class or make it static.

查看更多
在下西门庆
4楼-- · 2019-04-26 05:49

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);
查看更多
登录 后发表回答