Jump to content


C# Real World Help

  • Please log in to reply
7 replies to this topic

#1 Colin McGregor

Colin McGregor

    Neowinian Senior

  • Joined: 02-September 11
  • Location: Ontario, Canada
  • OS: Windows 8 x64, Gentoo x64 Sometimes
  • Phone: Samsung Ativ S WP8

Posted 07 August 2012 - 23:45

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?


public int thisVariablesName;
private int _thisVariablesName;

public void ThisVariable()

#2 BannanaNinja



  • Joined: 14-February 11
  • Location: US
  • OS: Windows 10
  • Phone: Windows 10 Mobile

Posted 08 August 2012 - 00:00

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).

#3 Andre S.

Andre S.


  • Tech Issues Solved: 17
  • Joined: 26-October 05

Posted 08 August 2012 - 01:01

Your new book seems to be following Microsoft's Design Guidelines : http://msdn.microsof...y/czefa0ke.aspx

Every company has its own conventions though. It's not very important which convention you use, as long as you use it consistently.

#4 garethevans1986



  • Joined: 01-April 04
  • Location: Gogledd Cymru / North Wales

Posted 08 August 2012 - 08:19

+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.


#5 articuno1au


    Neowinian Senior

  • Tech Issues Solved: 4
  • Joined: 20-March 11
  • Location: Brisbane, Australia

Posted 08 August 2012 - 08:41

+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 >.<

#6 Aethec


    Neowinian Senior

  • Joined: 02-May 10

Posted 08 August 2012 - 08:45

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

#7 James Rose

James Rose

    Software Developer

  • Tech Issues Solved: 1
  • Joined: 20-January 04
  • Location: New York City

Posted 13 August 2012 - 19:39

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.

#8 firey



  • Tech Issues Solved: 9
  • Joined: 30-October 05
  • Location: Alberta, Canada
  • OS: Windows 7
  • Phone: Android (4.4.2)

Posted 18 August 2012 - 22:18

I use camel case

myVariable for private

Pascal MyVariable for the public

And underscore for reserved words. ie) _object