Maha

Maha

  • NA
  • 0
  • 326.4k

method

Dec 4 2011 4:27 PM
In this program there is no call for test() method. Under these circumstances how it can output message (Using static constructor to initialize static data members ) in its content.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace static_eg
{
class Program
{
public class test
{
static string name;
static int age;

static test()
{
Console.WriteLine("Using static constructor to initialize static data members");
name = "John Sena";
age = 23;
}

public static void display()
{
Console.WriteLine("Using static function");
Console.WriteLine(name);
Console.WriteLine(age);
}
}

static void Main(string[] args)
{
test.display();

Console.ReadLine();
}
}
}
/*
Using static constructor to initialize static data members
Using static function
John Sena
23
*/

Answers (2)