Variable
Definition - What does
Variable
mean?
A variable, in C#, refers to a location in memory in which an application can store its data. Variables are used to store the result of calculations and hold the values that can change during the execution of a program. Variables are also used to place and retrieve the data forms an expression.
C# language is designed to be "type-safe," which helps ensure that the value stored in a variable is of the appropriate type. The type of a variable specifies what kind of data it can hold. This feature helps to reduce the burden from the programmer by guaranteeing the data's type safety.
Unlike loosely typed languages such as Jscript, C# expects the data type of a variable to be specified during declaration, which helps to allocate the memory for the variable during run time. In order to maintain the integrity of the data stored in a variable, C# defines a set of rules that dictate the permissible operations that can be performed on the variable.
Techopedia explains
Variable
A variable has to be declared before it is used. The declaration of a variable indicates its name, its type and an optional initial value. It is a good programming practice to assign a variable initially. A variable can be set to a value by an assignment or by using increment /decrement (++/--) operators. The scope of a variable determines its visibility to the program code and can be specified at the level of a class or method, or in nested code.
A variable can be a value or reference type. While variables of value type are stored on the stack, reference type variables are created on the heap with the reference to the allocated memory stored in the stack.
For example, a variable, "StudentName," can be declared as a string variable of reference type.
A variable that has been declared with a specific type cannot be redeclared with a new type. A variable of a particular type can be converted to another type using implicit type conversion or explicit conversion (cast). While implicit conversion does not incur any loss of data and occurs during compile-time, cast might cause data loss during run time.
This definition was written in the context of C#.
Home
Dictionary
Tags
Development
C Sharp
Related Terms
Data Type
Increment Operator (C#)
Decrement Operator (C#)
Assignment Operator (C#)
Cast (C#)
Related Videos
Related Links
Related White Papers
Other Resources
Related Tags
Categories:
.NET
C Sharp
Development
Tweet
Tweet
Popular White Papers
Techopedia Newsletter Sign-Up
Get Techopedia delivered to your inbox!
Term of the Day:
Get a new Techie Term sent to you every business day
Best of Techopedia:
We"ll bring you the best Techie articles each month.
Sign-In
Join Techopedia
Follow Us
Follow Techopedia on Facebook
Follow Techopedia on LinkedIn
Follow Techopedia on Twitter
Add Techopedia on Google Plus
Get Techopedia on RSS
Home
Dictionary
Articles
Tutorials
Newsletters
Development
Networks
Wireless
Support
Linux
Enterprise
Enterprise Apps
Security
CRM
IT Business
IT Careers
IT Management
Trends
Cloud Computing
Mobile computing
Personal Tech
Gaming
Internet
Search Engines
Social Media
World Wide Web
All Topics
Hacking
Online Marketing
Buzzwords and Jargon
Viruses
Operating Systems
Legal
People