Quantcast
Channel: Unity Forum
Viewing all articles
Browse latest Browse all 1466670

this. or underscore prefix in C#?

$
0
0
I've been programming in C# for 3 years and I've seen it done both ways. Normally I would say it's just a matter of opinion. But MonoBehaviour throws mud in the water by exposing lots of public fields in camelCase. So I'm wondering if one convention is better than the other for Unity.

Consider the following 2 code samples:

Code (CSharp):
  1.  
  2. _convention = "Underscore prefix ";         // Assign to a private field
  3. string myText = _codingConvention + name;   // name looks like a local variable...
this. or underscore prefix in C#?

Viewing all articles
Browse latest Browse all 1466670

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>