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
Sherbert LemonOP3y ago
ie what to use on public, private and method params
Pobiega
Pobiega3y 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
Pobiega3y ago
C# has an official naming convention, why not use that?
ero
ero3y ago
you can also enforce the official coding conventions by fetching a dotnet new editorconfig
Pobiega
Pobiega3y 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
ero3y ago
to add, fields should never be public
Pobiega
Pobiega3y ago
right. a "public field" should be a property instead, and those are also PascalCased
ero
ero3y 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
sibber3y ago
protected
ero
ero3y ago
i don't do that personally
Sherbert Lemon
Sherbert LemonOP3y ago
ok solved
sibber
sibber3y ago
dont do protected?
ero
ero3y ago
nah this i meant
Pobiega
Pobiega3y ago
to close your thread, use /close
Accord
Accord3y ago
✅ This post has been marked as answered!
sibber
sibber3y ago
ah
Want results from more Discord servers?
Add your server