Use var to define variables - CSharp Language Basics

CSharp examples for Language Basics:var

Description

Use var to define variables

Demo Code

using System;/*ww  w.ja  va 2  s.  c  o  m*/
class Program
{
   static void Main(string[] args)
   {
      var population = 66_000_000; // 66 million in UK
      var weight = 1.88; // in kilograms
      var price = 4.99M; // in pounds sterling
      var fruit = "Abc"; // strings use double-quotes
      var letter = 'Z'; // chars use single-quotes
      var happy = true; // Booleans have value of true or false
   }
}

Related Tutorials