Click here to Skip to main content
15,888,733 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralProduction code adds a BCC to email account of developer Pin
0bx24-Apr-13 5:48
0bx24-Apr-13 5:48 
AnswerRe: Production code adds a BCC to email account of developer Pin
AspDotNetDev24-Apr-13 5:54
protectorAspDotNetDev24-Apr-13 5:54 
GeneralRe: Production code adds a BCC to email account of developer Pin
BillW3325-Apr-13 9:17
professionalBillW3325-Apr-13 9:17 
GeneralRe: Production code adds a BCC to email account of developer Pin
AspDotNetDev25-Apr-13 9:20
protectorAspDotNetDev25-Apr-13 9:20 
GeneralRe: Production code adds a BCC to email account of developer Pin
agolddog26-Apr-13 3:41
agolddog26-Apr-13 3:41 
GeneralRe: Production code adds a BCC to email account of developer Pin
Bernhard Hiller25-Apr-13 3:54
Bernhard Hiller25-Apr-13 3:54 
GeneralRe: Production code adds a BCC to email account of developer Pin
RafagaX26-Apr-13 4:42
professionalRafagaX26-Apr-13 4:42 
GeneralNested if-else statements... PinPopular
Thomas Daniels23-Apr-13 7:21
mentorThomas Daniels23-Apr-13 7:21 
I found this in one of my old codes (it was a program to check whether a square was a magic square[^] or not)
C#
private void button1_Click(object sender, EventArgs e)
{
    int lefttop = Convert.ToInt16(_1.Text);
    int centertop = Convert.ToInt16(_2.Text);
    int righttop = Convert.ToInt16(_3.Text);
    int leftcenter = Convert.ToInt16(_4.Text);
    int centercenter = Convert.ToInt16(_5.Text);
    int rightcenter = Convert.ToInt16(_6.Text);
    int leftbottom = Convert.ToInt16(_7.Text);
    int centerbottom = Convert.ToInt16(_8.Text);
    int rightbottom = Convert.ToInt16(_9.Text);
    int row1 = lefttop + centertop + righttop;
    int row2 = leftcenter + centercenter + rightcenter;
    int row3 = leftbottom + centerbottom + rightbottom;
    int col1 = lefttop + leftcenter + leftbottom;
    int col2 = centertop + centercenter + centerbottom;
    int col3 = righttop + rightcenter + rightbottom;
    int dia1 = lefttop + centercenter + rightbottom;
    int dia2 = leftbottom + centercenter + righttop;
    if (row1 == row2)
    {
        if (row2 == row3)
        {
            if (row3 == col1)
            {
                if (col1 == col2)
                {
                    if (col2 == col3)
                    {
                        if (col3 == dia1)
                        {
                            if (dia1 == dia2)
                            {
                                MessageBox.Show("Your magic square is correct!");
                            }
                            else
                            {
                                MessageBox.Show("Wrong! Application will restart!");
                                this.Close();
                                Process restart = new Process();
                                restart.StartInfo.FileName = @"path name here";
                                restart.Start();
                            }
                        }
                        else
                        {
                            MessageBox.Show("Wrong! Application will restart!");
                            this.Close();
                            Process restart = new Process();
                            restart.StartInfo.FileName = @"path name here";
                            restart.Start();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Wrong! Application will restart!");
                        this.Close();
                        Process restart = new Process();
                        restart.StartInfo.FileName = @"path name here";
                        restart.Start();
                    }
                }
                else
                {
                    MessageBox.Show("Wrong! Application will restart!");
                    this.Close();
                    Process restart = new Process();
                    restart.StartInfo.FileName = @"path name here";
                    restart.Start();
                }
            }
            else
            {
                MessageBox.Show("Wrong! Application will restart!");
                this.Close();
                Process restart = new Process();
                restart.StartInfo.FileName = @"path name here";
                restart.Start();
            }
        }
        else
        {
            MessageBox.Show("Wrong! Application will restart!");
            this.Close();
            Process restart = new Process();
            restart.StartInfo.FileName = @"path name here";
            restart.Start();
        }
    }
    else
    {
        MessageBox.Show("Wrong! Application will restart!");
        this.Close();
        Process restart = new Process();
        restart.StartInfo.FileName = @"path name here";
        restart.Start();
    }
}

D'Oh! | :doh: D'Oh! | :doh: Dead | X| Dead | X|
The quick red ProgramFOX jumps right over the Lazy<Dog>.

My latest article: Understand how bitwise operators work (C# and VB.NET examples)

My group: C# Programmers Group

GeneralRe: Nested if-else statements... Pin
Akinmade Bond23-Apr-13 7:49
professionalAkinmade Bond23-Apr-13 7:49 
GeneralRe: Nested if-else statements... Pin
OriginalGriff23-Apr-13 8:12
mveOriginalGriff23-Apr-13 8:12 
GeneralRe: Nested if-else statements... Pin
StM0n23-Apr-13 9:48
StM0n23-Apr-13 9:48 
GeneralRe: Nested if-else statements... Pin
Monaco.Bavarian23-Apr-13 19:54
Monaco.Bavarian23-Apr-13 19:54 
GeneralRe: Nested if-else statements... Pin
Marius ten Napel24-Apr-13 1:51
Marius ten Napel24-Apr-13 1:51 
GeneralRe: Nested if-else statements... Pin
ZurdoDev24-Apr-13 2:10
professionalZurdoDev24-Apr-13 2:10 
GeneralRe: Nested if-else statements... Pin
Marius ten Napel24-Apr-13 2:36
Marius ten Napel24-Apr-13 2:36 
GeneralRe: Nested if-else statements... Pin
dusty_dex24-Apr-13 3:43
dusty_dex24-Apr-13 3:43 
GeneralRe: Nested if-else statements... Pin
NAANsoft24-Apr-13 2:44
NAANsoft24-Apr-13 2:44 
GeneralRe: Nested if-else statements... Pin
Lee Chetwynd24-Apr-13 5:07
Lee Chetwynd24-Apr-13 5:07 
GeneralRe: Nested if-else statements... Pin
RafagaX24-Apr-13 5:41
professionalRafagaX24-Apr-13 5:41 
GeneralRe: Nested if-else statements... Pin
tumbledDown2earth29-Apr-13 20:32
tumbledDown2earth29-Apr-13 20:32 
GeneralRe: Nested if-else statements... Pin
fulloflove2-May-13 17:19
fulloflove2-May-13 17:19 
GeneralRe: Nested if-else statements... Pin
Filipe Moreira de Oliveira18-May-13 8:00
Filipe Moreira de Oliveira18-May-13 8:00 
Answer[Solved] Why Do Computer Counts from Zero. Pin
kburman622-Apr-13 6:47
professionalkburman622-Apr-13 6:47 
GeneralRe: [Solved] Why Do Computer Counts from Zero. Pin
Marco Bertschi22-Apr-13 7:18
protectorMarco Bertschi22-Apr-13 7:18 
GeneralRe: [Solved] Why Do Computer Counts from Zero. PinPopular
Thomas Daniels22-Apr-13 7:25
mentorThomas Daniels22-Apr-13 7:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.