Write a code snippet to show non-parameterized constructor?

Posted by Tripati_tutu under C# category on | Points: 40 | Views : 2308
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NonParameterizedConst
class Program
int x;
public Program() // non-parameterized constructor
x = 10;
static void Main(string[] args)
Program obj1 = new Program();
Program obj2 = new Program();

In the above example the constructor will be invoked by the CLR for two times since two objects are created. In this the constructor will assign same value for all the objects.

Comments or Responses

Login to post response