AWPpr Shriom Gupta
AWPpr Shriom Gupta
class Program
{
static void Main(string[] args)
{
// Declare variables to store the four integers
int num1, num2, num3, num4;
OUTPUT:
Practical 1b: Create an application to demonstrate string
operations.
INPUT:
using System;
class Program
{
static void Main(string[] args)
{
string firstName = "shriom ";
string lastName = "gupta";
string fullName = firstName + " " + lastName;
Console.WriteLine("String Concatenation:");
Console.WriteLine(fullName);
Console.WriteLine();
OUTPUT:
class Program
{
static void Main(string[] args)
{
List<Student> students = new List<Student>();
while (true)
{
Console.WriteLine("Enter Student Information");
if (continueInput != "yes")
{
break;
}
}
OUTPUT:
// ============================
// Multilevel Inheritance
// ============================
public class Mammal : Animal
{
public void Walk()
{
Console.WriteLine("The mammal is walking.");
}
}
// ============================
// Hierarchical Inheritance
// ============================
public class Dog : Animal
{
public void Bark()
{
Console.WriteLine("The dog is barking.");
}
}
// ============================
// Multiple Inheritance (via Interfaces)
// ============================
public interface IPet
{
void Play();
}
// ============================
// Hybrid Inheritance (Using both Base Class and Interfaces)
// ============================
public class PetDog : Animal, IPet, IPlayable
{
public void Play()
{
Console.WriteLine("The dog is playing.");
}
public void Fetch()
{
Console.WriteLine("The dog is fetching the ball.");
}
}
// ============================
// Main Program (Demonstrating all types of Inheritance)
// ============================
class Program
{
static void Main()
{
Console.WriteLine("---- Single Inheritance Example ----");
Animal genericAnimal = new Animal();
genericAnimal.Eat();
OUTPUT:
NOTE: This example demonstrates all the different types of inheritance in C# running
together in a single program. You can observe how each type of inheritance works and how
they complement each other:
class Program
{
static void Main()
{
// Create instances of Publisher and Subscriber
Publisher publisher = new Publisher();
Subscriber subscriber = new Subscriber();