How To Declare Variables in C# 9

In this blog post we will learn how to declare vairiables in a C# 9 program.

Built-in Types

Since C# is a vibrant programing language, it comes with more than 30 variable types. Below are a few examples that will help you understand how to define variables.

int var = 10;  // int variable 
string name = "John" ;  // string
bool mybool = true; // Boolen
 

Print Variable

Once a variable has been declared we can easily access it and print it out to the console using the following example.

Console.WriteLine(name);

Published
Categorized as C#, C# 9

Leave a comment

Your email address will not be published. Required fields are marked *