Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Identifiers or Variables: Which is which?

I'm quite confused about several books in .NET that I have read. Would someone out there like to explain to me what an identifier is and how it differs from a variable? Or variables and identifiers are the same?

Thanks in advance.

like image 620
KG Sosa Avatar asked Jan 20 '09 08:01

KG Sosa


1 Answers

The difference between a variable and an identifier is the same as between a person and his or her name.

A variable is not an identifier. A variable has an identifier. It also has a type, and (if it is initialized) a value.

For example, the instruction:

bool isClosed = true;

declares and initializes a variable with name (identifier) isClosed, type bool, and value true.

Of course we normally say "isClosed is a variable..." "isClosed has a value of true"... but in the same way as we say "Peter is a software engineer", "John is tired"... that is, we refer to the variable by its name.

like image 170
Daniel Daranas Avatar answered Sep 19 '22 05:09

Daniel Daranas