Ad Code

Responsive Advertisement

C# keywords and Variables

C# keywords and Variables, Variables in programming languages are the space used to store data until it is used and needed. the value of these variables can change at any moment. you can give a name to each variable and the names of the variables must be different from each other so that no errors (errors) occur during the program execution process.


C# keywords and Variables



The correct way to write variable names in C Sharp


To use variables in C#, you must know how to create and choose names for variables in C#, as you must adhere to the following rules:


  • You have to choose meaningful names for the variables where they stand for the variable itself and anyone can understand the code of your program.
  • C# is case sensitive, meaning that the variable (myname) is different from the variable (MYNAME).
  • The variable name in C Sharp must not be a reserved word for this language.
  • The variable name can contain letters, numbers, and the underscore character (_).


Variable types in C#


1- Variables containing values


These types include all built-in types in C#:


Numeric variables: (byte, sbyte, short, ushort, int, uint, long, ulong, char).

Variables with a decimal point: (float, double).

Decimal numbers: (Decimal).

Boolean variables: (Boolean includes true, false).

Nullable variables.


2- Reference variables


It includes countless types of variables (struct, class, Enum).


  • abstract
  • bool 
  • continue
  • decimal
  • default
  • event 
  • explicit
  • extern
  • char 
  • checked 
  • class
  • const 
  • break
  • as 
  • base
  • delegate
  • is 
  • lock
  • long
  • num
  • byte
  • case
  • catch
  • false
  • finally
  • fixed
  • float
  • for
  • foreach
  • goto
  • if 
  • implicit
  • in
  • int 
  • interface
  • internal
  • do
  • double
  • else
  • namespace
  • new
  • null
  • object
  • operator
  • out
  • override
  • params
  • private
  • protected
  • public
  • readonly
  • sealed
  • short
  • sizeof
  • ref
  • return
  • sbyte
  • stackalloc
  • static
  • string
  • struct
  • void
  • volatile
  • while
  • true
  • try
  • switch
  • this
  • throw
  • unchecked
  • unsafe
  • ushort
  • using
  • using static
  • virtual
  • typeof
  • unit
  • ulong
  • out
  • add
  • alias
  • async
  • await
  • dynamic
  • from
  • get
  • orderby
  • ascending
  • descending
  • group
  • into
  • join
  • let
  • nameof
  • global
  • partial
  • set
  • remove
  • select
  • value
  • var
  • when
  • Where
  • yield