Getting Started - What To Know Before You Code

In Create Your First Console Application you learned how to create a new application project. In Common Windows of the Visual Studio IDE, you learned about the different areas of Visual Studio and how to utilize them. Simple Application Breakdown explained the different parts of the application. This post will show some of the tools and tips you will use when you start writing your applications.


Visual Studio allows you to add comments to your code file by starting the line with two forward slashes (//). There are multiple reasons why you would want to add comments.

Work Planning

Comments can be used to plan out your work before you start coding. This is where the TODO keyword is useful. By using TODO commenting, you build a task list of what you need to do.

By using comments to layout your strategy lets you focus on what the code needs to do, and not get caught up with the syntax of the code. These comments can also be useful if you are creating a skeleton of an application that someone else will complete. They allow you to show the overall plan without writing any code.

This detailed description of what an application will do is often referred to as "pseudo-code".


There is a saying that your code handles the "what", but your comments tell the "why". Many times applications are writing with business rules and logic that are not clear at first glance. Using comments to explain the why behind a process.

They are intended to inform anyone that works with your code to quickly understand what is happening in the code. This includes your future self. You may need to fix something six months after your code goes into production, and you will be thankful for the comment explaining why you made a particular coding decision.


Visual Studio has a code-completion tool called "intellisense" that attempt to aid your coding by providing information while you are typing. The intention of intellisense is to assist in speeding up your programming by avoiding misspellings, invalid syntax, and other mistakes commonly made by developers.

In the following clip, you will see Intellisense provide the developer with options as they type their code.

C# Syntax - Curly Braces and Semicolons

An application is made up of a series of actions that are executed in a certain order. The order the actions are executed is known as the application flow or the flow of execution.

Code Statements

Sometimes a single line of code is enough to perform the action. These lines of code are

called "statements". A semicolon is used to tell Visual Studio where that action ends. Think of it as a period at the end of a sentence. When you read a book, your mind understands that the period ends the concept you are currently reading, even if that sentence is four lines long. Visual Studio looks for the end of the code statement by seeking the semicolon.

Code Blocks

In C#, the curly braces "{}" are used to define a code block within the codebase. Curly braces mark where a logical concept starts and stops. You have already read about some of those logical concepts (namespaces, classes, methods), there are many more you will learn about in future posts (condition statements, loops, exception handling). Although the concepts are different, they all use curly braces.

An open curly brace "{" must always have a closing curly brace "}". When all braces are present they are considered "balanced" when one or more is missing the braces become "unbalanced". Unbalanced braces often result in compile errors that are difficult to track down. Luckily, newer versions of Visual Studio assist in tracking down unbalanced braces by creating dashed lines from the open brace to the closing one.

Note to New Developers

One of the hardest things for beginning developers to get used to is remembering when to end a line of code with a semicolon and when to use curly braces. The only way to get better at this is to write code. Eventually, it will click, but it not before spending way too much time tracking down difficult syntax errors and unhelpful squiggles. Stick with it, and one day it will become second-nature.

111 views0 comments

Recent Posts

See All