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

Hallo

Ich hätte mal ne theoretische frage. Ich arbeite mit c#

Hier erstmal ein kleines (sehr einfaches) szenario:

Ich hab eine Klasse, z.B.


    public class SimpleClass

    {

        public SimpleClass(double val)

        {

            this.val = val;

        }

        public double Val

        {

            get { return val; }

            set

            {

                val = value;

            }

        }

        public void Increment()

        {

            this.Val++;

        }

        public void Decrement()

        {


            this.Val--;

        }

        private double val;

    }

Nur möchte ich aus einer Windows-Form (oder einer anderen Klasse) heraus wissen, wieviel funktionen diese klasse hat.

Ich dachte da an i-was in der richtung. Mit ner foreach-schleife über die klasse gehen.

Hoffe es is klar was ich mein.

Geht das i-wie???

Prinzipiell kannst Du per Reflection über den Typ eines Objects alle Methoden dieses Typs auflisten.

Beispiel (ungetestet):



KlasseIrgendwas a = new KlasseIrgendwas();

Type t = a.GetType();

MethodInfo[] methods = t.GetMethods();


foreach (MethodInfo mi in methods)

{

      Console.WriteLine(mi.Name);

}


dieses müsste Dir alle "Public" Methoden eines Typs ausgeben. Um andere Methoden zu bekommen, kannst Du entweder das MemberInfo direkt benutzen oder eine andere Überladung von "GetMethods" aufrufen.

  • 4 Wochen später...
  • Autor

Ok, das mit den Methoden auflisten klappt.

Nun habich ein weiteres problem. Etz wenn ich alle Funktionen aufgelistet habe, ordne ich jedem Namen einen Button zu. Wenn der Button gedrückt wird, dann soll diese Funktion aufgerufen werden.

Weiß einer von euch zufällig wie ich das anstelle???

Ich hab hier ja nur den Namen der Funktion als String. Wie bekomme ich daraus jetzt nen funktionsaufruf???

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.