A variable is just a storage for data of values in the program. In programming world, every variables has a datatype and in most programming language, C# included, a variable's datatype is determined when the variable is declared or initialized. There are several ways to declare a variable:
For example:
The first and third example above only declare variables, they don't assign any value to the variables. An empty variable must be assigned a value before being read. If an empty variable is read, a runtime error will occur. While the second and fourth example have already assigned values to the variables so that the variables are ready to be read. If a variable is empty when being read, a runtime error will occur.
The datatypes used above are the most common datatype used, int is an integer, string is a collection of characters, and double is a real number. We will learn about datatypes in the next part of this tutorial.
2019 © Pasar Kode-V3.
Privacy Policy |
Term of Service |
Language Contributor |
English |
Best view in Mozilla