Home / .NET / Variables used in C# development
about the basic variables used in C#.

Variables used in C# development

On day 1 on the C# development, we should be aware about the basic variables used in C#.

Variables:

Variables are like the store unit needed for the data storage while executing any program.

In C# variables are declared as below:

<data type><name>

E.g. int a; string str;

The data types used to create a variables are of two types,

  1. Values Types:

The data types which are used to store the data which is allocated to the itself is called value types. The variable initialized as a value data type contains the value in it. The value types are stored in the stack memory.

E.g.  Byte, int, float, char, double, decimal, bool etc.

  1. Reference Types:

The data types which holds the address/reference of the data are called reference types. The reference types are stored in the heap memory.

E.g.  string, object.

 

Boxing & Unboxing:

Boxing:

Conversion of value of value type into value of reference type.

In boxing conversion permits any value type to be converted to the object type.

E.g.    int a=1;

object b=a; //boxing

Unboxing:

Conversion of value of reference type into value of value type.

In unboxing we perform explicit conversion of object type into value type.

E.g.     object b=12;

int a=( int )b; //unboxing

Operators:

Operators in C# are as below.

Arithmetic operators:

These include the operators used for mathematical purpose, like addition, subtraction, multiplication, division, modulus, increment & decrement operators.

  1. Addition (+)
  2. Subtraction (-)
  3. Multiplication (*)
  4. Division (/)
  5. Modulus (%)
  6. Increment (++)
  7. Decrement (–)

Logical Operators:

These include the operators which are used to perform logical operations like AND, OR & NOT.

  1. AND (&&)
  2. OR (||)
  3. NOT (!)

Relational Operators:

These includes the operators which are used for comparison purpose, like EQUAL TO, GREATER THAN & SMALLER THAN.

  1. EQUAL TO (==)
  2. NOT EQUAL TO (! ==)
  3. GREATER THAN (>)
  4. SMALLER THAN (<)
  5. GREATER THAN OR EQUAL TO (>=)
  6. SMALLER THAN OR EQUAL TO (<=)

 

About Helpservices

About This site (allhelpservices.com) is dedicated to helping other bloggers learn the skills of blogging, wordpress, education, technology, social media sharing , SEO, Electronics, Earn Money From Blogging, Web hosting and web share their own experiences and promote the blogging medium. We started Allhelpservices in August 2015 mainly because we wanted to keep a record of what we wear learning from development and because we wanted to connect with other learners.

Check Also

ASP.NET and PHP

What is the difference between ASP.NET and PHP ?

ASP.NET and PHP both are server side technologies; PHP is open source and ASP.NET own ...

Leave a Reply