合同要求某种共享方法 [英] Contract to require a certain shared method
问题描述
我试图编写一个接口,需要实现
类才能有一个共享函数,CanAdd()作为boolean,它决定当前用户是否b / b
可以添加特定类的新实例。这个
授权是在类级别,而不是实例级别,所以它应该共享
,但我找不到一种方法来要求一个类来
通过接口实现共享方法。有什么建议吗?
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?
推荐答案
布莱恩,
Luckely你可以在VB中用AFAIK创建混合模式类(一些需要一个
构造函数,一些不允许构造函数)。
Legency这是C语言。
Cor
" Bryan" < br ******* @ bermail.com的gmail.comschreef
新闻:11 ********************** @ e65g2000hsc.googlegr oups.com ...
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...
>我试图编写一个需要实现
类的接口一个共享函数,CanAdd()作为布尔值,它决定当前用户是否可以添加特定类的新实例。这个
授权是在类级别,而不是实例级别,所以它应该共享
,但我找不到一种方法来要求一个类来
通过接口实现共享方法。有什么建议吗?
>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?
" Cor Ligthert [MVP]" < no ************ @ planet.nlschrieb:
"Cor Ligthert [MVP]" <no************@planet.nlschrieb:
Luckely你可以在VB中使用AFAIK而不是创建混合模式类(其中一些是需要
a构造函数和一些不允许构造函数的构造函数。
Luckely you can AFAIK in VB not create mixed mode classes (some which need
a constructor and some which don''t allow a constructer).
与OP'问题的关系是什么?
What''s the relation to the OP''s question?
Legency this in in C语言。
Legency this is in the C languages.
至少不在C中,因为C根本不支持课程。
-
MS Herfried K. Wagner
MVP< URL:http://dotnet.mvps.org/>
VB< URL:http:/ /dotnet.mvps.org/dotnet/faqs/>
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/>
" Bryan" < br ******* @ gmail.comschrieb:
"Bryan" <br*******@gmail.comschrieb:
>我试图编写一个需要实现的界面
类有一个共享函数,CanAdd()为boolean,它决定当前用户是否可以添加特定类的新实例。这个
授权是在类级别,而不是实例级别,所以它应该共享
,但我找不到一种方法来要求一个类来
通过接口实现共享方法。有什么建议?
>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?
这在VB中是不可能的(在C#中也是如此)。但是,为什么不定义包含该方法的
基类?但请注意,
根本无法覆盖共享方法。
-
MS Herfried K .Wagner
MVP< URL:http://dotnet.mvps.org/>
VB< URL:http://dotnet.mvps.org/ dotnet / faqs />
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/>
这篇关于合同要求某种共享方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!