Autor Beitrag
DonKannallie
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Di 12.08.14 18:20 
Hallo Com.

ausblenden volle Höhe C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
int weiß = 0;


private void Form1_load(object sender,EventArgs e)
{
    label1.Text=Convert.toString(weiß);

}
public void Klicken (Object sender , MouseEventArgs e )
{
    

    Panel panelClicked = (Panel)sender;

    switch (e.Button)
    {
        case MouseButtons.Left:
            {
                panelClicked.BackColor = Color.Black;
                break;
                weiß--;<- Unerreichbarer Code wurde entdeckt
                
            }
        case MouseButtons.Right:
            {
                panelClicked.BackColor = Color.White;
                break;
                weiß++;<- Unerreichbarer Code wurde entdeckt
            }
        case MouseButtons.Middle:
            {
                panelClicked.BackColor = Color.Red;
                break;
                weiß--;<- Unerreichbarer Code wurde entdeckt
            }
    }



Wieso kann ich mit dem swtich case keine variablen ansprechen?

(Ich will dass wenn sich die farbe des Objektes ändert der int wert "weiß" mit der änderung mit geht)
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4803
Erhaltene Danke: 1060

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Di 12.08.14 18:42 
Hallo,

kennst du (nicht) die Bedeutung von break?
DonKannallie Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Di 12.08.14 18:59 
doch , aber darauf hab ich jetzt gar nicht geachtet...-.- :D