By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,109 Members | 993 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,109 IT Pros & Developers. It's quick & easy.

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

P: n/a
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,ISWPH andleException

{

...

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(st ring)'.
'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.
Nov 15 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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.

"Ben R. Bolton" <ns****@xbridgesystems.com> wrote in message
news:O8****************@TK2MSFTNGP09.phx.gbl...
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,ISWPH andleException

{

..

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(st ring)'.
'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.

Nov 15 '05 #2

P: n/a
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
"Malek" <ke****@arrabeta.com> wrote in message
news:ee****************@TK2MSFTNGP09.phx.gbl...
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.

"Ben R. Bolton" <ns****@xbridgesystems.com> wrote in message
news:O8****************@TK2MSFTNGP09.phx.gbl...
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,ISWPH andleException

{

..

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(st ring)'.
'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.


Nov 15 '05 #3

P: n/a
compiles fine when I try it ... did you close and reopen VS ?

"Ben R. Bolton" <ns****@xbridgesystems.com> wrote in message
news:ud**************@TK2MSFTNGP10.phx.gbl...
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
"Malek" <ke****@arrabeta.com> wrote in message
news:ee****************@TK2MSFTNGP09.phx.gbl...
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.

"Ben R. Bolton" <ns****@xbridgesystems.com> wrote in message
news:O8****************@TK2MSFTNGP09.phx.gbl...
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,ISWPH andleException

{

..

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(st ring)'.
'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.



Nov 15 '05 #4

P: n/a
Makek,

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

Ben

"Malek" <ke****@arrabeta.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
compiles fine when I try it ... did you close and reopen VS ?

"Ben R. Bolton" <ns****@xbridgesystems.com> wrote in message
news:ud**************@TK2MSFTNGP10.phx.gbl...
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
"Malek" <ke****@arrabeta.com> wrote in message
news:ee****************@TK2MSFTNGP09.phx.gbl...
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.

"Ben R. Bolton" <ns****@xbridgesystems.com> wrote in message
news:O8****************@TK2MSFTNGP09.phx.gbl...
> 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,ISWPH andleException
>
> {
>
> ..
>
> 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(st ring)'.
> '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.
>
>



Nov 15 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.