Source Code


  • Fandi Susanto
  • 14 November 2013 at 17:13
  • C Sharp
  • 854
  • 9
  • United States

Author: Fandi Susanto Language: United States
License: Freeware
Size: 0 KB
Downloads: 20 times


A variable is just a storage for data of values in the program. In programming world, every variables has a datatype and in most programming language, C# included, a variable's datatype is determined when the variable is declared or initialized. There are several ways to declare a variable:

  • [data type] [identifier];
  • [data type] [identifier] = [value];
  • [data type] [identifier 1], [identifier 2], [identifier N];
  • [data type] [identifier 1] = [value 1], [identifier 2] = [value 2], [identifier N] = [value N];

For example:

  • int totalItemCount;
  • string customerName = Fandi;
  • double price1, price2, price3;
  • int amount1 = 10, amount2 = 7, amount3 = 12;

The first and third example above only declare variables, they don't assign any value to the variables. An empty variable must be assigned a value before being read. If an empty variable is read, a runtime error will occur. While the second and fourth example have already assigned values to the variables so that the variables are ready to be read. If a variable is empty when being read, a runtime error will occur.

The datatypes used above are the most common datatype used, int is an integer, string is a collection of characters, and double is a real number. We will learn about datatypes in the next part of this tutorial.

comments powered by Disqus

Related Code

Database Connection

Reading From Database

Rich-Text Editors for Web

Alpha Control

Restful Webservice Call And Get And Parse JSON Data

Camera Video Capture And Save On SDCard

Simple Code Javascript


Try Command

Rapid CSS Editor 2007


Tag Linked