473,390 Members | 1,300 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,390 software developers and data experts.

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 3319
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: AH | last post by:
I have two functions in my shared library which are declared as follows: void setName(const std::string& str); std::vector<std::string> getInfo(); Since the code is compiled and in shared...
39
by: JKop | last post by:
Back when I read my first C++ book, I was given the following scenario: class Cheese { public: int number_of_holes; int colour;
5
by: TruongLapVi | last post by:
Hi, Why C# does not support Interface static member ? Some time I want implement NullObject Pattern: public interface INullObject { public static INullObject Null { get { return...
14
by: Joe Fallon | last post by:
I am trying to build a Data Access Layer for a SQL Server back end. My class has a number of methods in it. The constructor takes a connection string. I currently have to instantiate an object...
4
by: a | last post by:
Hello Gang, I am in a bit of confusion regarding a half completed application I am writing. It is an MDI app, so I have a main form (frmMain) that is always open. I am looking for a 'Best...
2
by: Elephant | last post by:
Hello, question, I want to make a COM-compatible .NET DLL (Visual Basic). For this I need an interface. The DLL has a class that must contain methods that can be used without making an instance...
15
by: Bob Johnson | last post by:
I have a base class that must have a member variable populated by, and only by, derived classes. It appears that if I declare the variable as "internal protected" then the base class *can*...
2
by: Ronald S. Cook | last post by:
I was thinking about the methods in our "service" project (business tier). Is there any issue with implementing static (shared) methods over Windows Communication Foundation (WCF)? If not, I think...
11
by: eBob.com | last post by:
I have this nasty problem with Shared methods and what I think of as "global storage" - i.e. storage declared outside of any subroutines or functions. In the simple example below this "global"...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.