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

Require shared member implementation using Interfaces

P: n/a
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
Share this Question
Share on Google+
4 Replies


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

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

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

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