473,395 Members | 1,456 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,395 software developers and data experts.

Contract to require a certain shared method

I was trying to write an interface that would require the implementing
class to have a shared function, CanAdd() as boolean, which decides if
the current user can add a new instance of the particular class. This
authorization is at the class level, not the instance level, so it
should be shared, but I cannot find a way to require a class to
implement a shared method via an interface. Any suggestions?

May 18 '07 #1
10 2621
Bryan,

Luckely you can AFAIK in VB not create mixed mode classes (some which need a
constructor and some which don't allow a constructer).

Legency this is in the C languages.

Cor
"Bryan" <br*******@gmail.comschreef in bericht
news:11**********************@e65g2000hsc.googlegr oups.com...
>I was trying to write an interface that would require the implementing
class to have a shared function, CanAdd() as boolean, which decides if
the current user can add a new instance of the particular class. This
authorization is at the class level, not the instance level, so it
should be shared, but I cannot find a way to require a class to
implement a shared method via an interface. Any suggestions?

May 18 '07 #2
"Cor Ligthert [MVP]" <no************@planet.nlschrieb:
Luckely you can AFAIK in VB not create mixed mode classes (some which need
a constructor and some which don't allow a constructer).
What's the relation to the OP's question?
Legency this is in the C languages.
At least not in C because C doesn't support classes at all.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

May 18 '07 #3
"Bryan" <br*******@gmail.comschrieb:
>I was trying to write an interface that would require the implementing
class to have a shared function, CanAdd() as boolean, which decides if
the current user can add a new instance of the particular class. This
authorization is at the class level, not the instance level, so it
should be shared, but I cannot find a way to require a class to
implement a shared method via an interface. Any suggestions?
That's simply not possible in VB (and in C# too). However, why not define a
base class containing the method? However, note that it's not possible to
override shared methods at all.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

May 18 '07 #4

">
What's the relation to the OP's question?
see your own kind of an echo, nothing wrong with in this case.
>Legency this is in the C languages.

At least not in C because C doesn't support classes at all.
C#
May 18 '07 #5
Cor,

"Cor Ligthert [MVP]" <no************@planet.nlschrieb:
>>Legency this is in the C languages.

At least not in C because C doesn't support classes at all.

C#
Even C# does not support static members implementing a member defined in an
interface.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

May 18 '07 #6
??

"Herfried K. Wagner [MVP]" <hi***************@gmx.atschreef in bericht
news:ui**************@TK2MSFTNGP03.phx.gbl...
Cor,

"Cor Ligthert [MVP]" <no************@planet.nlschrieb:
>>>Legency this is in the C languages.

At least not in C because C doesn't support classes at all.

C#

Even C# does not support static members implementing a member defined in
an interface.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

May 19 '07 #7
http://msdn2.microsoft.com/en-us/lib...s3(VS.80).aspx

Maybe is this answering what you are writing. This is not in VB.Net although
you can call in my idea the module a little like that.

Cor

"Herfried K. Wagner [MVP]" <hi***************@gmx.atschreef in bericht
news:ui**************@TK2MSFTNGP03.phx.gbl...
Cor,

"Cor Ligthert [MVP]" <no************@planet.nlschrieb:
>>>Legency this is in the C languages.

At least not in C because C doesn't support classes at all.

C#

Even C# does not support static members implementing a member defined in
an interface.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

May 19 '07 #8
"Cor Ligthert [MVP]" <no************@planet.nlschrieb:
http://msdn2.microsoft.com/en-us/lib...s3(VS.80).aspx

Maybe is this answering what you are writing. This is not in VB.Net
although you can call in my idea the module a little like that.
Behind the scenes modules and static classes share certain similarities, but
semantically they are different constructs used for different purposes.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

May 19 '07 #9
That's simply not possible in VB (and in C# too). However, why not define a
base class containing the method? However, note that it's not possible to
override shared methods at all.

--
M S Herfried K. Wagner
I can't make the member part of a base class because it needs to
behave differently for each class. The method needs to be shared, and
I would just like to avoid any sort of late binding method calling.
May 19 '07 #10
"Bryan" <br*******@gmail.comschrieb:
>That's simply not possible in VB (and in C# too). However, why not define
a
base class containing the method? However, note that it's not possible
to
override shared methods at all.

I can't make the member part of a base class because it needs to
behave differently for each class. The method needs to be shared, and
I would just like to avoid any sort of late binding method calling.
Maybe you can utilize the Factory design pattern.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

May 19 '07 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: John Brock | last post by:
I have a base class with several derived classes (I'm writing in VB.NET). I want each derived class to have a unique class ID (a String), and I want the derived classes to inherit from the base...
4
by: Bennett Haselton | last post by:
If I add this to my web.config file: <authentication mode="Forms"> <forms name=".ASPXUSERDEMO" loginUrl="login.aspx" protection="All" timeout="60" /> </authentication> I can configure the...
2
by: tshad | last post by:
I have a program I am trying to compile into a dll and am getting a bunch of: the following errors: error BC30469: Reference to a non-shared member requires an object reference. At first, I...
0
by: JosAH | last post by:
Greetings, This tip of the week introduces a bit of theory when it comes to Object Oriented programming. First we indroduce a little example project: a simple geometry project. We want to define...
0
by: Anthony Paul | last post by:
Hello everyone! I have been looking for information regarding the SOA tenet of decoupling the client interface from the web service interface. I understand the value of not sharing a contract...
81
by: Russ | last post by:
I just stumbled onto PEP 316: Programming by Contract for Python (http://www.python.org/dev/peps/pep-0316/). This would be a great addition to Python, but I see that it was submitted way back in...
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"...
3
by: Lance Wynn | last post by:
Hello, I am receiving this error when trying to instantiate a webservice component. I have 2 development machines, both are XP sp2 with VS 2008 installed. On one machine, the code works fine. On...
5
by: ahgan | last post by:
Hi, For some reasons, I have to keep my sub-programs in 2 different .pl files. Both sub-programs are having the same subroutine name. In my main program, I need to determine which sub-program to...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.