469,283 Members | 2,297 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,283 developers. It's quick & easy.

Require shared member implementation using Interfaces

Hi there,

I would like to develop an interface that when implemented in a class
requires a number of shared properties or methods to be available. It seems
a Shared Member can not be used as interface member implementation?!

Is there a workaround to this problem?!

Best regards,
Philippe Rubbrecht
Nov 21 '05 #1
4 3018
This is not a problem, you are just looking at it from the wrong
perspective. When you choose to implement and interface, you are making a
statement that 'I will implement this interface', the paramaters passed to
the functions/sub and those returned by the functions are external to the
class. Any implementation which is done in the class which 'Implements' this
interface is up to the class designer.

You on the other hand seem to be suggesting that the interface itself has an
implementation. Interfaces can have the following defined; Properties,
Events, Members or Types.

Maybe I have misunderstood you, if after reading this reply you think I have
could you be more specific

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Rubbrecht Philippe" <ph****************@ugine-alz.arcelor.com> wrote in
message news:e%****************@tk2msftngp13.phx.gbl...
Hi there,

I would like to develop an interface that when implemented in a class
requires a number of shared properties or methods to be available. It seems a Shared Member can not be used as interface member implementation?!

Is there a workaround to this problem?!

Best regards,
Philippe Rubbrecht

Nov 21 '05 #2
Let me give you a small example of what I'm trying to do:

I want every assembly that is developed in my team to provide an
"AssemblyInfo" class that provides a number of properties and methods for
that assembly. For example, I want a SHARED Property or Function
"Environment" to be available that states the name of the environment
(Development, Test, Acceptance or Production) that the assembly is currently
running in.

Therefore I tried to develop an interface "IAssemblyInfo" that needs to be
implemented in every assembly to make sure that these properties and methods
become available.

However, the class that implements this interface can not define this
implemented property of function to be Shared!
It seems to be impossible to have Shared members as an interface member
implementation!?
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:eN**************@TK2MSFTNGP09.phx.gbl...
This is not a problem, you are just looking at it from the wrong
perspective. When you choose to implement and interface, you are making a
statement that 'I will implement this interface', the paramaters passed to
the functions/sub and those returned by the functions are external to the
class. Any implementation which is done in the class which 'Implements' this interface is up to the class designer.

You on the other hand seem to be suggesting that the interface itself has an implementation. Interfaces can have the following defined; Properties,
Events, Members or Types.

Maybe I have misunderstood you, if after reading this reply you think I have could you be more specific

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Rubbrecht Philippe" <ph****************@ugine-alz.arcelor.com> wrote in
message news:e%****************@tk2msftngp13.phx.gbl...
Hi there,

I would like to develop an interface that when implemented in a class
requires a number of shared properties or methods to be available. It

seems
a Shared Member can not be used as interface member implementation?!

Is there a workaround to this problem?!

Best regards,
Philippe Rubbrecht


Nov 21 '05 #3
Yes thats correct. Interfaces do not have any implementation, they are
simply templates. For example, you cannot define a member variable, only a
property, your member functions and subs can only be signatures and may not
have implementation.

Why not create a class library which return these values which are
applicable to the assembly, and have them stored in the App.config. file as
a value/key pair. This way you only need add a reference to your assembly
and ensure that the values are in the config file.

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Rubbrecht Philippe" <ph****************@ugine-alz.arcelor.com> wrote in
message news:eZ**************@TK2MSFTNGP10.phx.gbl...
Let me give you a small example of what I'm trying to do:

I want every assembly that is developed in my team to provide an
"AssemblyInfo" class that provides a number of properties and methods for
that assembly. For example, I want a SHARED Property or Function
"Environment" to be available that states the name of the environment
(Development, Test, Acceptance or Production) that the assembly is currently running in.

Therefore I tried to develop an interface "IAssemblyInfo" that needs to be
implemented in every assembly to make sure that these properties and methods become available.

However, the class that implements this interface can not define this
implemented property of function to be Shared!
It seems to be impossible to have Shared members as an interface member
implementation!?
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message news:eN**************@TK2MSFTNGP09.phx.gbl...
This is not a problem, you are just looking at it from the wrong
perspective. When you choose to implement and interface, you are making a statement that 'I will implement this interface', the paramaters passed to the functions/sub and those returned by the functions are external to the class. Any implementation which is done in the class which 'Implements' this
interface is up to the class designer.

You on the other hand seem to be suggesting that the interface itself

has an
implementation. Interfaces can have the following defined; Properties,
Events, Members or Types.

Maybe I have misunderstood you, if after reading this reply you think I

have
could you be more specific

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Rubbrecht Philippe" <ph****************@ugine-alz.arcelor.com> wrote in
message news:e%****************@tk2msftngp13.phx.gbl...
Hi there,

I would like to develop an interface that when implemented in a class
requires a number of shared properties or methods to be available. It

seems
a Shared Member can not be used as interface member implementation?!

Is there a workaround to this problem?!

Best regards,
Philippe Rubbrecht



Nov 21 '05 #4
* "Rubbrecht Philippe" <ph****************@ugine-alz.arcelor.com> scripsit:
I would like to develop an interface that when implemented in a class
requires a number of shared properties or methods to be available. It seems
a Shared Member can not be used as interface member implementation?!


This scenario cannot be described using VB.NET syntax. Notice that
shared members cannot be overridden.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

39 posts views Thread by JKop | last post: by
5 posts views Thread by TruongLapVi | last post: by
14 posts views Thread by Joe Fallon | last post: by
2 posts views Thread by Elephant | last post: by
2 posts views Thread by Ronald S. Cook | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.