Professional Documents
Culture Documents
Day 20
Day 20
----
Create an interface IProduct having the following methods
string GetBrand()
string GetPrice()
string GetQuality()
Instance variable:
string brand
double price
string quality generate properties for these variables
Instance variable:
string title
double price
string quality generate properties for these variables
Create another class with name Test write main method in that and create object for
both Laptop and Book classes
Excepted Output:
--------------------
Laptop Details:Brand: HP
Price: $1200.5
Quality: High
Online Shopping App Name: Flipcart
Item added to the cart.
Checkout completed.
string GetPickupLocation()
string GetDropLocation()
Instance variables:
string pickupLocation
string dropLocation generate properties for the variables
Create another class with name Test write main method in that and create object for
Taxi class
Excepted output:
----------------
Taxi Booking Details:
Pickup Location: Airport
Drop Location: City Center
Taxi Booking App: Ola
Booking confirmed. Taxi en route.
Q3:
----
using System;
namespace DelegateBasics
{
// Step 1: Declare a delegate with the same signature as the method you want to
assign to it.
public delegate void MyDelegate();
class Program
{
static void Main(string[] args)
{
// Step 2: Create an instance of the delegate and assign a method to
it.
MyDelegate myDelegate = new MyDelegate(SayHello);
Q4:
-----
using System;
namespace MulticastDelegates
{
// Step 1: Declare a delegate with the same signature as the methods you want
to assign.
public delegate void MultiDelegate();
class Program
{
static void Main(string[] args)
{
// Step 2: Create instances of the delegate and assign multiple methods
to it.
MultiDelegate multiDelegate = Method1;
multiDelegate += Method2;
multiDelegate += Method3;
Console.ReadKey();
}
using System;
namespace DelegateOperatorsExample
{
public delegate void MyDelegate();
class Program
{
static void Main(string[] args)
{
MyDelegate myDelegate = null; // Initialize the delegate to null
Console.ReadKey();
}