Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Implement interface member error

Status
Not open for further replies.

tramimaus

IS-IT--Management
Sep 23, 2004
15
US
Hi!

I'm getting this implement interface member error. I'm not sure, if I'm missing something. Can somebody help me out? thaaaaaanks!

This is the code from the class that derives from the interface :

using System;

namespace Arithmetic
{
/// <summary>
///
/// </summary>
public class Calculations : Arithmetic.ICalculations
{
public Calculations()
{
Numb1 = Numb2 = 0;
}

#region ICalculations Members

public int Operand1
{
get
{

return Numb1;
}
set
{
Numb1 = value;
}
}

public int Operand2
{
get
{
return Numb2;
}
set
{
Numb2 = value;
}
}

public int Add(int a, int b)
{

return (a + b);
}

public int Multiply(int a, int b)
{

return (a * b);
}

public int Subtract(int a, int b)
{
return (a - b);
}

public int Divide(int a, int b)
{

return (a / b);
}

#endregion

private int Numb1;
private int Numb2;

}
}


And here is the code for the interface:

using System;

namespace Arithmetic
{
/// <summary>
///
/// </summary>
interface ICalculations
{

int Operand1
{
get;
set;
}

int Operand2
{
get;
set;
}

int Add();

int Multiply();

int Subtract();

int Divide();
}
}


thank you!!
 
it's because the method signatures in the interface are not the same with the ones in the implementing class

take for instance the Add method. in the interface it has no parameters while in the implementation it has 2 (int a, int b)

modify the interface add to look like
int Add (int a, int b)
and it should work

modify all the methods too be correctly defined and you won't have any problems.

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top