CSharp - What is the output: Fields elements?


What is the output of the following code?

using System;
class MainClass
   static int x;
   public static void Main(string[] args)
      Console.WriteLine (x); 

Click to view the answer



The code outputs 0, because fields are implicitly assigned a default value

Fields elements are automatically initialized with the default values for their type.

Related Quiz