interface

vb.net: multiple inheritance in an interface

会有一股神秘感。 提交于 2019-12-10 02:07:58
问题 I'm facing a problem regarding multiple inheritance in VB.net: As far as I know VB.net does not support multiple inheritance in general but you can reach a kind of multiple inheritance by working with interfaces (using “Implements” instead of “Inherits”): Public Class ClassName Implements BaseInterface1, BaseInterface2 End Class That works fine for classes but I’d like to have an interface inheriting some base interfaces. Something like that: Public Interface InterfaceName Implements

Implementing interfaces in partial classes

China☆狼群 提交于 2019-12-10 02:04:23
问题 Consider a class which implements a lot of interfaces, would it make sense to implement each interface in a separate file using partial class definitions? Would this be an abuse of the language feature or is it an idiom I'm unaware of? 回答1: If your class has to implement many interfaces, that's a reasonable way of managing the source, yes. You can edit the project file to make several of them depend on one "main" class file, which makes the Solution Explorer easier to work with. You should

Why are interfaces not allowed as annotation members?

Deadly 提交于 2019-12-10 01:54:50
问题 Consider this code: @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface Bar { Foo foo() default FooImpl.FooConstant; } Compiler error: annotation value not of an allowable type If I replace Foo with FooImpl the code is accepted. What's the reason for this behavior? 回答1: If I replace Foo with FooImpl the code is accepted. I would be very surprised if this compiled, unless FooImpl is an enum. Annotation members may only contain the following: primitive type String

Should I return CompletableFuture or Future when defining API?

送分小仙女□ 提交于 2019-12-10 01:45:56
问题 In Java 8, is it better for interface or abstract class to define APIs returning CompletableFuture instead of returning Future ? Considering it is ugly converting Future to CompletableFuture and the fact that CompletableFuture will give the caller more flexibility of using functional style directly, what could be a good reason for an API to just return Future ? 回答1: My 2 cts: by returning a Future, you keep your options open and can return a Future, or a CompletableFuture - it makes no

In Delphi, how can you check if an IInterface reference implements a derived but not explicitly-supported interface?

我们两清 提交于 2019-12-10 01:27:03
问题 If I have the following interfaces and a class that implements them - IBase = Interface ['{82F1F81A-A408-448B-A194-DCED9A7E4FF7}'] End; IDerived = Interface(IBase) ['{A0313EBE-C50D-4857-B324-8C0670C8252A}'] End; TImplementation = Class(TInterfacedObject, IDerived) End; The following code prints 'Bad!' - Procedure Test; Var A : IDerived; Begin A := TImplementation.Create As IDerived; If Supports (A, IBase) Then WriteLn ('Good!') Else WriteLn ('Bad!'); End; This is a little annoying but

PHP can't extend from interface?

ε祈祈猫儿з 提交于 2019-12-10 01:27:00
问题 I write below in a single php file. <?php interface people { public function take($s); } class engineer extends people { public function take($s){ echo $s; } } ?> The people is an interface, the engineer extends people. But when I run this code, the error: Fatal error: Class engineer cannot extend from interface people in E:\php5\Mywwwroot\b.php on line 12 What's happened? My PHP version is 5.4. 回答1: You implement interfaces and extend classes: <?php interface people { public function take($s

typescript extend an interface as not required

拥有回忆 提交于 2019-12-10 00:50:03
问题 I have two interfaces; interface ISuccessResponse { Success: boolean; Message: string; } and interface IAppVersion extends ISuccessResponse { OSVersionStatus: number; LatestVersion: string; } I would like to extend ISuccessResponse interface as Not Required; I can do it as overwrite it but is there an other option? interface IAppVersion { OSVersionStatus: number; LatestVersion: string; Success?: boolean; Message?: string; } I don't want to do this. 回答1: A bit late, but Typescript 2.1

Why is my Angular template throwing this Typescript error?

社会主义新天地 提交于 2019-12-09 22:49:52
问题 I'm building an Angular 4 project in Typescript 2.3.4 . I can't figure out what's wrong with the code below. IDialog interface export interface IDialog{ cancellable?: boolean, inputs?: Array<{label: string, value?: any, description?: string}|string> message: string title?: string, type?: DialogInputTypes // <- an Enum } SampleComponent.ts public dialog:IDialog = { cancellable:false, title:'Dialog Title', message:'This is a modal dialog', type:DialogInputTypes.button, inputs:[ {label:'OK',

Reusable non generic method for generic methods

回眸只為那壹抹淺笑 提交于 2019-12-09 20:27:43
问题 I have the following base interface public interface IHandler{ void Handle(IMessage message); } and an generic interface inheriting the base interface public interface IHandler<TMessage> : IHandler where TMessage : IMessage{ void Handle(TMessage message); } My classes can implement the interface IHandler<TMessage> mutiple times. IMessage is an base interface for messages and isn´t relevant here. Currently i´m implementing the interfaces as follows. public class ExampleHandler : IHandler

Interfacing with super and subclass constructors

白昼怎懂夜的黑 提交于 2019-12-09 18:36:01
问题 I have had trouble finding help in the matlab documentation and previous questions about using matlab inheritance and class constructors to make an interface. To make it tidy, within a package. Instead of dragging through my code I can condense it as follows: A package +MyPkg has a superclass Super and a few subclasses Sub1 Sub2 ... Most of my properties and methods are defined in Super such that Sub1 and Sub2 really only exist to use their constructors for simple routines or perhaps a few