Where are Variables Stored?
In this lesson, you'll get the idea of how variables are stored in the memory.
We'll cover the following
Introduction
A variable is a place in memory where the application can store some type of information.
You can think of memory as an "array of
bytes
". Eachbyte
possesses a memory address.
Upon variable declaration, a memory location is reserved for that variable.
Example
For example, we declare an int
variable which covers 4 bytes and a char
variable which spans over 2 bytes of memory:
using System;namespace VariablesExampleOne{class Program{static void Main(string[] args){int myInt;char myChar;}}}
You’ll learn more about variables’ types ahead.
💡Note: 1 byte = 8 bits
Cool, right? Let’s learn the variable syntax in the next lesson.