CSharp examples for Language Basics:var
use var keyword with more data types: arrays and collections.
using System;/*from w ww. j a v a 2s.co m*/ using System.Collections.Generic; class Program { static void Main(string[] args) { // Use var for an array. var numbers = new[] { 1, 2, 3 }; Console.WriteLine("Array initializer: "); foreach (int n in numbers) { Console.WriteLine(n.ToString()); } // This writes "System.Int32[]". Console.WriteLine(numbers.GetType().ToString()); } }