Hacker News new | ask | show | jobs
by imstate 1942 days ago
The opening bracket in a new line is very common for C/C++ and C#.

Obviously Standards change, but that's what we learned when I went to school.

The only thing that should matter with style is consistency.

2 comments

IIRC some old unix book recommended splitting type declaration, prototype and body on different lines, like this:

    int
    myFunc(char *str, int strlen)
    {
         <body>
    }
with the rationale being that grepping for ^myFunc (or searching for it in vi) would have found the function declaration immediately.

Not sure I like that, anyway.

Agree. It hasn't changed, it's still what Microsofts C# style guide recommends.

https://docs.microsoft.com/en-us/dotnet/csharp/programming-g...

It's also what VS Code autoformats even C++ to by default.

Also I wonder if the other commenters reflexively saying "SQL injection" realize that is just the symptom; the underlying problem is that LINQ is not used. Even if the SQL injection was fixed, a literal SQL query is usually not the right tool in C#.