What is a variable?
In C#, as with any programming language, a variable simply represents an allocation of a computer’s memory – like a bucket. Once we have declared our variable bucket, we can then put values into the bucket, retrieve values from the bucket, or completely change the contents of the bucket. This analogy helps us understand how we can use variables, but there is still more we need to know
Let’s consider the size of container I would need in order to hold a giant boulder. I will not be able to put a boulder into a small beach pail. The beach pail is not the right size bucket for the item I want to store. In the same way, variables come in different sizes for storing different types of data. Some variables will hold numeric values, some will hold a string of alphanumeric characters, and some will hold date/time values. It is important to declare variables of an appropriate data type based on the values we wish to store in the variable.