Help understanding why compiler needs to qualify one method and not the other.

  • Thread starter Thread starter Ben R. Bolton
  • Start date Start date
B

Ben R. Bolton

I have two projects each with a different namespace. The first defines an
interface with two methods.



namespace SWPStandards

{

public interface ISWPDisplayMessage

{

void DisplayMessage(string message);

void DisplayMessage(string message, bool popUp);

}



}



the second implements the interface.



namespace BRBWinTester

{

public class Form1 :
System.Windows.Forms.Form,ISWPDisplayMessage,ISWPHandleException

{

...

public void DisplayMessage(string message, bool popUp)

{

statusBar1.Text = message;

if (popUp)

MessageBox.Show(message);

}



void DisplayMessage(string message)

{

DisplayMessage(message,SWP.Const.NoPopUP);

}



}

}



I have implemented the two required methods one both without qualifying the
method with SWPStandards.ISWPDisplayMessage. Why does the compiler generate
the following exception?





'BRBWinTester.Form1' does not implement interface member
'SWPStandards.ISWPDisplayMessage.DisplayMessage(string)'.
'BRBWinTester.Form1.DisplayMessage(string)' is either static, not public, or
has the wrong return type.



Why doesn't it generate the same message for the other method?



Any assistance would be appreciated.
 
in your code, in the class implementing the interface, the first method is
public, the second is not ... the problem is not on FQN for the methods, but
ob the modifier ...

an interface only lists public methods.
by default, members of a class are protected.
 
Malek,
Thanks for you quick response. Unfortunately that is not the issue.
Changing method drfinition to


public void DisplayMessage(string message)

{

DisplayMessage(message,SWP.Const.NoPopUP);

}



generates the same error.


Ben
 
Makek,

Well closing and reopening the IDE solved the problem (grumble grumble)..
Thanks for you help.

Ben
 
Back
Top