Lesson 4: String variables
Until now we printed text directly. Now we'll store text under a name to reuse it. In C# you declare a string variable like this: string name = "Dana";. The word string is the type (what kind of value), name is the name, and = puts the value in. Then you write the name without quotes to get the valu
A variable is a labeled box. string name = "Dana"; puts the text Dana in a box called name. When you write name (no quotes), you get what's in the box.
- variable
- A name that stores a value so you can reuse it.
- string (type)
- The word that declares the variable will hold text.
- assignment =
- The sign that puts the value on the right into the variable on the left.
- name vs literal
- name (no quotes) is the value in the variable; "name" (with quotes) is the word name itself.