Skip to content

Error on int in if statement

A Repasky

Asked Jan 19, 2013, 4:04 PM EST2 answers
Share
LinkedInX
I have this defined in one class:

public
static int ProfCnt = 0;

Then I need to in another class use in an if statement:

if (History.CountProfRec != 0)

But I get error:

Error 1 Operator '==' cannot be applied to operands of type 'method group' and 'int' 
Does anyone know what I have to do?
Thanks for the help,
arep.

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Akkiraju Ivaturi
    0
    I believe History.CountProfRec is a method and so you need to call it by History.CountProfRec() which returns an int value so that you can compare with other int value.

    By the way the code you have provided is not clear. I am answering you based on the error you specified. This error occurs if you call a method with no "()".
    0
  • 0
    I fixed the problem.  All it was a change of != to >,'

    if (History.CountProfRec > 0)

    arep
    0