What "internal" says is that a given entity is only visible within the
assembly in which is resides (its definition in the case of interfaces).
public, obviously, gives everything access to it.

What this error is saying is that you've given anyone access to your Bar
class; but only internal classes have access to the return value of the
Clone() method.  Since enforcement of access is done at compile time, this
is an error.

Since interfaces have a default access of public the Clone method must be
define as public.  To get around error CS0050 you can make your Bar class
consistent with your IFoo interface by making it internal as well.

internal interface IFoo {
 IFoo Clone();
}
internal class Bar : IFoo {
 public IFoo Clone() {
  return null;
 }
}

The alternative is to make IFoo public.  I'm assuming you want something
internal and suggested making Bar internal first.

Why would you choose to make an interface internal?

http://www.peterRitchie.com/

On Fri, 7 Oct 2005 20:24:12 -0400, Daniel Michaeloff <[EMAIL PROTECTED]
LABS.NET> wrote:

>Hi all,
>
>If you have an interface declared as "internal":
>
> internal interface IFoo {
>  IFoo Clone();
> }
>
>can it ever be used by a class at "public"?
>
> public class Bar : IFoo {
>  public IFoo Clone() {
>   return null;
>  }
>        }
>
>Visual Studio gives "return type IFoo is less accessible than method
>Bar.Clone()".  But if you use internal instead:
>
> public class Bar : IFoo {
>  internal IFoo Clone() {
>   return null;
>  }
>        }
>
>you get "does not implement interface member Clone().  Clone() is either
>static, not public, or has the wrong return type."
>
>Is this by design?

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to