Autor Beitrag
felix96
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 34


VS 2010 Express
BeitragVerfasst: Di 14.09.10 20:42 
ausblenden C#-Quelltext
1:
2:
3:
4:
        public static void mach_alles_unsichtbar
        {
                Form1.button1.Visible = false;
        }


Hier kommt aber der Fehler
Fehler 1 get- oder set-Accessor erwartet.


Moderiert von user profile iconChristian S.: Topic aus Basistechnologien verschoben am Di 14.09.2010 um 20:51
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Di 14.09.10 20:50 
Bei einer Methode kommen doch noch die Klammern hinter den Namen :-)

P.S.: Und von einer statischen Methode aus wird das, was Du vorhast, eh nicht klappen :zwinker:

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
felix96 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 34


VS 2010 Express
BeitragVerfasst: Di 14.09.10 20:53 
Dann kommt das:
Fehler 1 Für das nicht statische Feld, die Methode oder die Eigenschaft "WindowsFormsApplication1.Form1.button1" ist ein Objektverweis erforderlich.
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Di 14.09.10 20:54 
Siehe mein post scriptum ...

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
felix96 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 34


VS 2010 Express
BeitragVerfasst: Di 14.09.10 20:56 
Hä?
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Di 14.09.10 20:58 
Wenn Du aus einer statischen eine nicht-statische Methode machst, musst Du Dir schon überlegen, wie Du die gesamte Methode ändern musst. Nur das "static" wegmachen, reicht nicht.

Überleg Dir mal, worauf Du zugreifen willst aus der Instanzmethode, die Du ohne "static" bekommst. Und lies die Fehlermeldung nochmal. Und schlag die Fehlermeldung auch mal in der Doku nach :-)

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
felix96 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 34


VS 2010 Express
BeitragVerfasst: Di 14.09.10 21:03 
Wie wärs denn richtig?
public void mach_alles_unsichtbar()

In der Hilfe kommt dieser Fehler:
Das angeforderte Thema wurde in der lokalen Hilfe nicht gefunden.
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Di 14.09.10 21:08 
Ja, die Methodensignatur ist richtig. Das ist aber nur die halbe Lösung. Nochmal: Worauf willst Du zugreifen? Genauer: Auf den Button welcher Form?

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
felix96 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 34


VS 2010 Express
BeitragVerfasst: Di 14.09.10 21:11 
Form1
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Di 14.09.10 21:24 
Form1 ist eine Klasse, Du willst aber auf den Button einer bestimmten Form (= Instanz dieser Klasse) zugreifen.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".