Name : Shoeb S.
Sem: V Roll No : 23DBIT02
Class : T.Y.BSCIT
---------------------------------------------------------------------------------------------------------
Practical 2a Subject: AWD
AIM : Create a simple application to demonstrate the concepts boxing and
unboxing.
❖ Program :
using System;
namespace Prac2a
{
internal class Program
{
static void Main(string[] args)
{
int num = 2020;
object obj = num;
num = 100;
System.Console.WriteLine("Value - type of num is : {0}", num);
System.Console.WriteLine("Object - type value of obj is
{0}", obj); Console.ReadLine(); int i =
(int)obj;
System.Console.WriteLine("Value - type of num is : {0}", i);
System.Console.WriteLine("Object - type value of obj is {0}", obj);
Console.ReadLine();
}}}
❖ Output:
Practical 2b
AIM : Create a simple application to perform addition and subtraction using
delegate
❖ Program :
using System;
namespace Prac2b
{
internal class Program
{
public delegate int Operation(int x, int
y); static void Main(string[] args)
{
Operation addOperation = new Operation(Add);
Operation subtractOperation = new
Operation(Subtract); int a = 2; int b = 5;
int additionResult = addOperation(a, b);
Console.WriteLine($"Addition of {a} and {b} =
{additionResult}"); int subtractionResult =
subtractOperation(a, b);
Console.WriteLine($"Subtraction of {a} and {b} =
{subtractionResult}"); Console.ReadKey();
}
static int Add(int x, int y)
{ return
x + y;
}
static int Subtract(int x, int y) { return x - y; }
}
}
❖ Output:
Practical 2c
AIM : Create a simple application to demonstrate use of the concepts of
interfaces.
❖ Program :
using System;
namespace Prac2c
{
public interface Animal
{
void MakeSound();
}
public class Dog : Animal
{
public void MakeSound()
{
Console.WriteLine("Dog says: Woof!");
}
}
// Implementing the Animal interface in the Cat
class public class Cat : Animal
{
public void MakeSound()
{
Console.WriteLine("Cat says: Meow!");
}
}
internal class Program
{
static void Main(string[] args)
{
Animal myDog = new Dog();
Animal myCat = new Cat();
myDog.MakeSound();
myCat.MakeSound();
Console.ReadLine();
}
}
}
❖ Output:
--------------------------------------------------------------------------------------------------------------------------------------
“ AIKTC Panvel ”
BSC IT Department
Subject : Advanced Web Programming
Lab Activity in Practical 2
Marks obtained Signature
Product Process Total (25)
Related (15) Related (10)