C# is stupid

Sometimes C# just torques me off. Especially when it doesn’t give useful errors. I wrote the following line of code:
if (((string)e.Row.Cells[3].Value = "Yes")) {}
Which of course should have been:
if (((string)e.Row.Cells[3].Value == "Yes")) {}

The errors I got were:

The left-hand side of an assignment must be a variable, property or indexer

and

Cannot implicitly convert type 'string' to 'bool'

Why can’t it just say:

Hey stupid C#-wannabe former-VB.NET-programmer, you meant '=='.

Instead I spent 5 minutes trying different things before I noticed the typo.

D'oh!

Posted on January 26, 2006 in .NET. 2 comments   

2 Comments

  1. Jeremy said:

    That’s how they weed out the wannabe’s. If you need logical error messages and sensical syntax you might want to put your training wheels back on and go back to a little toy language like “VB”

    What’s next….you want error messages that help you troubleshoot problems when an application crashes?

    Or how about a CMS that is easy to use and runs efficiently?

    I think its time you come back to reality(); or is it Reality();

  2. Dan said:

    Got another one for yas:

    I typed this because I was Java-retarded:
    char tokens[] = Message.Split(” “);

    The error? Oh, so descriptive I crapped my pants with joy:
    Syntax error, bad array declarator. To declare a managed array the rank specifier precedes the variable’s identifier

    The fix?

    char[] tokens = Message.Split(” “);

    Better error?
    Put [] after the type, not the variable name.

    I gotta go clean up now.

(Comments are moderated.)