44
1
using System;
2
using System.Threading;
3
4
public class Program
5
{
6
public static void Main()
7
{
8
9
TwoInstance T1 = new TwoInstance();
10
TwoInstance T2 = new TwoInstance();
11
TwoInstance T3 = new TwoInstance(); // this will throw an error :)
12
}
13
14
public class TwoInstance
15
{
16
private static int countInstances=1;
17
//*if you want to get the count outside then make it
18
//public or create a static int method which will return this property*
19
20
public TwoInstance()
21
{
22
Console.WriteLine("Instance" + countInstances + "Created");
23
24
// countInstances++; *this is the basic thing which came
Cached Result