Local variables must be assigned a value before they can be read. - CSharp Language Basics

CSharp examples for Language Basics:Variable

Description

Local variables must be assigned a value before they can be read.

Demo Code

using System;/* ww w  . j  a  v  a 2 s. c om*/
class Test
{
   static void Main(){
      //int x;
      //Console.WriteLine (x);        // Compile-time error
      int[] ints = new int[2];
      Console.WriteLine (ints[0]);    // 0
   }
}

Result


Related Tutorials