C
Join ServerC#
help
Naming conventions [Answered]
SLSherbert Lemon11/5/2022
I am arguing with my friend about what casing to use in variable names. To settle the argument whatever the first naming convention that someone says (within reason say the actual one that you use) we will use
SLSherbert Lemon11/5/2022
ie what to use on public, private and method params
PPobiega11/5/2022
C# has an official naming convention, why not use that?
EEro11/5/2022
you can also enforce the official coding conventions by fetching a
dotnet new editorconfig
PPobiega11/5/2022
to summarise it, types (classes, records, structs etc) and methods get
PascalCase
names, local variables and parameters get camelCase
names and private fields get _underscoreCamelCase
namesEEro11/5/2022
to add, fields should never be public
PPobiega11/5/2022
right. a "public field" should be a property instead, and those are also
PascalCased
EEro11/5/2022
fields should only ever be
private
, private protected
, or protected
. properties are protected internal
, internal
, public
EEro11/5/2022
feel like i'm missing one
EEro11/5/2022
the convention to add
s_
to static things isn't a great one imoCCyberrex11/5/2022
protected
EEro11/5/2022
i don't do that personally
SLSherbert Lemon11/5/2022
ok solved
CCyberrex11/5/2022
dont do protected?
EEro11/5/2022
nah this i meant
PPobiega11/5/2022
to close your thread, use
/close
AAccord11/5/2022
✅ This post has been marked as answered!
CCyberrex11/5/2022
ah