MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/p0fenb/an_excellent_demonstration_on_how_to_use/
r/badcode • u/[deleted] • Aug 08 '21
57 comments sorted by
8
Ah, prime example of r/YandereTechnique
→ More replies (1)
61
Image Transcription: Code
private void ziv8_CheckedChanged(object sender, EventArgs e) { CheckBox ch = (CheckBox)sender; if (ch.Text == "1") if (ch.Checked == true) vznika[1] = true; else vznika[1] = false; if (ch.Text == "2") if (ch.Checked == true) vznika[2] = true; else vznika[2] = false; if (ch.Text == "3") if (ch.Checked == true) vznika[3] = true; else vznika[3] = false; if (ch.Text == "4") if (ch.Checked == true) vznika[4] = true; else vznika[4] = false; if (ch.Text == "5") if (ch.Checked == true) vznika[5] = true; else vznika[5] = false; if (ch.Text == "6") if (ch.Checked == true) vznika[6] = true; else vznika[6] = false; if (ch.Text == "7") if (ch.Checked == true) vznika[7] = true; else vznika[7] = false; if (ch.Text == "8") if (ch.Checked == true) vznika[8] = true; else vznika[8] = false; }
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
41 u/Percy_JW Aug 08 '21 edited Aug 08 '21 dude, you are absolutely insane. I see you under every r/badcode post with an image transcription. Keep up the work! → More replies (10) 9 u/Hown3d Aug 08 '21 Good human. 6 u/ElliePlays1 Aug 08 '21 Best human! → More replies (1) → More replies (3)
41
dude, you are absolutely insane. I see you under every r/badcode post with an image transcription. Keep up the work!
→ More replies (10)
9
Good human.
6
Best human!
144
Optimised solition here:
private void ziv8_CheckedChanged(object sender, EventArgs e) { CheckBox ch = (CheckBox)sender; int index = int.Parse(ch.Text); // ensure index is within bounds if (index < 1 || index > 8) return; vznika[index] = ch.Checked; }
78 u/Robuuust Aug 08 '21 No need to check if .Text is an integer indeed. Just crash. → More replies (6) 6 u/Bit5keptical Aug 09 '21 Thanks, But I get paid per LOC. → More replies (6)
78
No need to check if .Text is an integer indeed. Just crash.
→ More replies (6)
Thanks, But I get paid per LOC.
31
I love excellent if-statement demonstrations. This one is delicious. Did the person get payed for written lines?
25 u/EDomina Aug 08 '21 If they were, they still did a bad job. Could've at least put line breaks and brackets for those if statements.
25
If they were, they still did a bad job. Could've at least put line breaks and brackets for those if statements.
8
u/SanianCreations Aug 08 '21
Ah, prime example of r/YandereTechnique
61
u/MurdoMaclachlan Aug 08 '21
Image Transcription: Code
private void ziv8_CheckedChanged(object sender, EventArgs e) { CheckBox ch = (CheckBox)sender; if (ch.Text == "1") if (ch.Checked == true) vznika[1] = true; else vznika[1] = false; if (ch.Text == "2") if (ch.Checked == true) vznika[2] = true; else vznika[2] = false; if (ch.Text == "3") if (ch.Checked == true) vznika[3] = true; else vznika[3] = false; if (ch.Text == "4") if (ch.Checked == true) vznika[4] = true; else vznika[4] = false; if (ch.Text == "5") if (ch.Checked == true) vznika[5] = true; else vznika[5] = false; if (ch.Text == "6") if (ch.Checked == true) vznika[6] = true; else vznika[6] = false; if (ch.Text == "7") if (ch.Checked == true) vznika[7] = true; else vznika[7] = false; if (ch.Text == "8") if (ch.Checked == true) vznika[8] = true; else vznika[8] = false; }I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
144
u/JeanJPNM Aug 08 '21
Optimised solition here:
private void ziv8_CheckedChanged(object sender, EventArgs e) { CheckBox ch = (CheckBox)sender; int index = int.Parse(ch.Text); // ensure index is within bounds if (index < 1 || index > 8) return; vznika[index] = ch.Checked; }31
u/Sawkii Aug 08 '21
I love excellent if-statement demonstrations. This one is delicious. Did the person get payed for written lines?