Naming conventions [Answered]

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
16 Replies
Sherbert Lemon
ie what to use on public, private and method params
Pobiega
Pobiega2y ago
C# Coding Conventions
Learn about coding conventions in C#. Coding conventions create a consistent look to the code and facilitate copying, changing, and maintaining the code.
Pobiega
Pobiega2y ago
C# has an official naming convention, why not use that?
ero
ero2y ago
you can also enforce the official coding conventions by fetching a dotnet new editorconfig
Pobiega
Pobiega2y ago
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 names
ero
ero2y ago
to add, fields should never be public
Pobiega
Pobiega2y ago
right. a "public field" should be a property instead, and those are also PascalCased
ero
ero2y ago
fields should only ever be private, private protected, or protected. properties are protected internal, internal, public feel like i'm missing one the convention to add s_ to static things isn't a great one imo
sibber
sibber2y ago
protected
ero
ero2y ago
i don't do that personally
Sherbert Lemon
ok solved
sibber
sibber2y ago
dont do protected?
ero
ero2y ago
nah this i meant
Pobiega
Pobiega2y ago
to close your thread, use /close
Accord
Accord2y ago
✅ This post has been marked as answered!
sibber
sibber2y ago
ah