Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Grüße,

mich beschäftigt seit einiger Zeit das Problem, ob es möglich ist eine Property eines Interfaces mit Interfacevererbung umzubenennen.

Bei einfacher expliziter Interfaceimplementierung ist dies ja einfach realisierbar:


Interface IFooBar

    Property FooBar() As Double

End Interface


Class FooBar : Implements IFooBar


    Public Property FooBar() As Double

        Get

            '...

        End Get

        Set(ByVal value As Double)

            '...

        End Set

    End Property


    Public Property IFooBarsFooBar() As Double Implements IFooBar.FooBar

        Get

            '...

        End Get

        Set(ByVal value As Double)

            '...

        End Set

    End Property

End Class

Da dacht ich mir, wenn das so geht, dann kann ich auch noch ein Interface dazwischenschalten, welches die Eigenschaft des Interfaces einfach umbenennt:

Interface A

    Property foo() As Double

End Interface


Interface B : Inherits A

    Property bar() As Double Implements A.foo

End Interface


Class C : Implements B


    Public Property bar() As Double Implements B.bar

        Get

            '...

        End Get

        Set(ByVal value As Double)

            '...

        End Set

    End Property

End Class

Funktioniert so aber nicht, weil:

Class 'C' must implement 'Property foo() As Double' for interface 'A'. Implementing property must have matching 'ReadOnly' or 'WriteOnly' specifiers.

Warum ist das so?

Ich hab doch in B geschrieben, dass die Property bar gleichzeitig die Property foo repräsentiert.

Gibt es da irgend eine Möglichkeit oder ist das nicht machbar?

Wenn ich das noch richtig im Kopf habe, ist die Vererbung eine Menge:

Deine Klasse B ist eine Obermenge von C und A Obermenge von B, das impliziert dass A ebenfalls Obermenge von C ist und somit muss in C alles aus A implementiert sein und zusätzlich das aus B

HTH Phil

  • Autor

Ja, aber wenn ich sage, dass B.bar gleichzeitig A.foo implementiert müsste das doch heißen, dass A.foo implementiert ist, wenn B.bar implementiert wurde. :confused:

Komische Sprache...

Interface B : Inherits A

B erbt von A - das heißt, B besitzt foo von A, auch wenn du in der Schnittstelle A.foo durch bar implementierst.

Einfach die Vererbung rauslassen

Interface B

und es sollte gehen. ;)

  • Autor

B erbt von A - das heißt, B besitzt foo von A, auch wenn du in der Schnittstelle A.foo durch bar implementierst.

Einfach die Vererbung rauslassen

Die Vererbung von A kann ich nicht rauslassen, da einige Funktionen einen A-Typ als Parameter brauchen.

Das Problem entsteht nur wegen der besseren Lesbarkeit, aber wenns nicht geht, ist das auch ok...

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.