Live data from Hacker News

A matter of style in C#

news.ycombinator.com

11–14 of 14 posts

Re: A matter of style in C#

#11
post #2

Well, if you're not idiomatic with C# yet, that would be the very first place I'd start (by that I mean you know why you'd use StringBuilder vs. string concatenation, etc). After that, make sure you're good about commenting code that isn't immediately obvious. From that point, I'm afraid we'd probably need some samples to see where you might be going wrong or right.

I definately know some of the inner workings of.Net, such as using StringBuilder compared to string concatenation. Some of the things I need to know is what is an acceptible name for a variable based on its scope. For instance currently to describe a private variable belonging to a class I will prefix it with an underscore. Is there a universal way of denoting varibles by scope?

The standard (citing from memory) is to use Properties in uppercase (PascalCase) and fields in lowercase (camelCase) with NO prefix whatsoever but preceed them with "this." whenever referenced. parameters are also lowercase (camelCase) with NO prefix whatsoever and are thus difference of local variables by the absence of the "this.". However, this doesn't answer the static fields and Properties...

Re: A matter of style in C#

#12
post #6

Earlier quoted context omitted.

I definately know some of the inner workings of.Net, such as using StringBuilder compared to string concatenation. Some of the things I need to know is what is an acceptible name for a variable based on its scope. For instance currently to describe a private variable belonging to a class I will prefix it with an underscore. Is there a universal way of denoting varibles by scope?

I'd try taking a look at "IDesign C# Coding Standard, for development guidelines and best practices" from here: http://idesign.net/idesign/DesktopDefault.aspx (This is the direct download link: http://idesign.net/idesign/download/IDesign%20CSharp%20Codin... )

I would second this - it has a lot of good info for C# folks.

Re: A matter of style in C#

#14
post #6

Earlier quoted context omitted.

I definately know some of the inner workings of.Net, such as using StringBuilder compared to string concatenation. Some of the things I need to know is what is an acceptible name for a variable based on its scope. For instance currently to describe a private variable belonging to a class I will prefix it with an underscore. Is there a universal way of denoting varibles by scope?

I'd try taking a look at "IDesign C# Coding Standard, for development guidelines and best practices" from here: http://idesign.net/idesign/DesktopDefault.aspx (This is the direct download link: http://idesign.net/idesign/download/IDesign%20CSharp%20Codin... )

This is an excellent article. I follow alot of the guidlines already but there is some important ones that I am missing. Thank you.
Post reply on HN