• 0

C# Real World Help


Question

When i originally learned C# i learned basically with notepad and a compiler and I was taught to use camel case (thisVariablesName) for public, underscore (_thisVariablesName) for private and pascal (ThisVariablesName) for method names. Now im using a book to learn WPF and WinForms C# programming and the 2 books i have is using pascal for public variables and for methods and camel case for private.

My question is once i get employment in the real world with development is there a common way that most companies use? or is the books right and im doing it wrong originally?

Eg:

public int thisVariablesName;

private int _thisVariablesName;

public void ThisVariable()

{

}

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

For private variables, I do it the same way as your public variables (camel case without the underscore), as I normally don't have any public variables anyway. Sometimes companies have their own specific paradigm which they tell will you, but if they don't, code similar to the rest of the code so yours will fit in (like if curly braces go to the next line or not and such).

For the most part though it's not a big deal (there isn't a right and wrong).

Link to comment
Share on other sites

  • 0

+1 to what Dr_Asik said.

If you use a product called ReSharper you can set the rules up in there and share them between a team.

GE

Link to comment
Share on other sites

  • 0

+1 for resharper.

A developer friend recommended it to me. I couldn't live without it now. It's awesome for LINQ stuff <3+

As observed by others, what rules you use are less important than using a set consistently. Just learn what your company expects and do it >.<

Link to comment
Share on other sites

  • 0

The most important rule IMHO: Do not use Hungarian notation, ever.

Not to start an argument, but I think it's worth mentioning that there are values to Hungarian Notation. I should also state that I have spent 20 years using VB where Hungarian is used quite often. The real answer here is that each place you work will have patterns and that each pattern has it's benefits and it's issues. Learning to deal with change is part of the development cycle.

Good luck.

Link to comment
Share on other sites

  • 0

I use camel case

myVariable for private

Pascal MyVariable for the public

And underscore for reserved words. ie) _object

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.