Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Name: Muhammad Fawad

ID Name: 12699
Course: OOP Lab
LAB TASK NO. 7

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

namespace ConsoleApp3
{
class Program
{
class Test
{
public static int count = 0;

public Test()
{
count = count + 1;
}
}
static void Main(string[] args)
{
Test obj1 = new Test();
Test obj2 = new Test();
Test obj3 = new Test();
Test obj4 = new Test();
Console.WriteLine("total Instances = {0}", Test.count);
Console.ReadKey();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ChatApplication
{
class Program
{
class Client
{
public static int count;

public Client()
{
count++;
}
}
class Server
{
Client obj = new Client();
Client obj1 = new Client();
Client obj2 = new Client();
Client obj3 = new Client();
Client obj4 = new Client();

public void Show()


{
Console.WriteLine("Alert! Total Instances of Client is
{0}",Client.count);
}
}
static void Main(string[] args)
{
Server ServerObj = new Server();
ServerObj.Show();
Console.ReadKey();
}
}
}

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

namespace ModifyClientClass
{
class Program
{
class Client
{
public string ClientMess;

}
class Server
{
Client obj = new Client();

public void Show()


{
obj.ClientMess = "Creating Client";
Console.WriteLine(obj.ClientMess+"......");
}

static void Main(string[] args)


{
Server server = new Server();
server.Show();
Console.ReadKey();
}
}
}

You might also like