From the course: Visual Studio 2019 Essential Training

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Get consistent code with code styles

Get consistent code with code styles - Visual Studio Tutorial

From the course: Visual Studio 2019 Essential Training

Start my 1-month free trial

Get consistent code with code styles

- [Instructor] It's nice to check your code and ensure that it meets your personal or team rules. In Visual Studio this is easy to check with the code style feature. There are two categories of rules, code standards and name standards. In this video, I'll look at code standards. Here's an example on line 11. I'm declaring a list of string. And I'm using the var keyword to do that. On line 12, I'm using the explicit type to declare a list of string. Both of these examples are valid C#. Our team may have a preference of whether we use the var keyword or explicit type, and what I'd like to be able to foreset across all our code base. Here's another example on line 30. I've got an if statement and an L statement, and I've got a single line of code, so I don't need curly braces. But if I start adding additional lines of code I will need some curly braces. Some teams like to enforce this and say it doesn't matter how many lines of code you have, if you have any code within the if statement,…

Contents