Operators, Types and Variables in C#

CsharpProgrammingServer Side Programming

Variables in C#

A variable is a name given to a storage area that our programs can manipulate. Each variable in C# has a specific type, which determines the size and layout of the variable's memory the range of values that can be stored within that memory and the set of operations that can be applied to the variable.

Types in C#

The variables in C#, are categorized into the following types: Value, Reference and Pointer types.

Value types

Value type variables can be assigned a value directly. They are derived from the class system.ValueType.

Reference types

The reference types do not contain the actual data stored in a variable, but they contain a reference to the variables.

Using multiple variables, the reference types can refer to a memory location. If the data in the memory location is changed by one of the variables, the other variable automatically reflects this change in value. Example of built-in reference types are: object, dynamic, and string.

Pointer types

Pointer type variables store the memory address of another type.

Operators in C#

An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations.

The following are the operators −

  • Arithmetic Operators
  • Relational Operators
  • Logical Operators
  • Bitwise Operators
  • Assignment Operators
Published on 14-Aug-2018 16:08:22