THDC INSTITUTE OF HYDROPOWER
ENGINEERING AND TECHNOLOGY
Assignment 2
.net framework and c#
BCST 701
Submitted By
PRASHANT DHIMAN
(210970101027)
CSE IV Year
Submitted To
Mr. Ravindra Rawat
Assistant Professor
Computer science and engineering dept.
GET SET CODE :
using System;
public class Student
private string name;
private int age;
// Property for Name with get and set
public string Name
get { return name; }
set { name = value; }
// Property for Age with get and set
public int Age
get { return age; }
set
if (value > 0)
age = value;
}
else
Console.WriteLine("Age must be positive.");
public class Program
public static void Main(string[] args)
Student student = new Student();
student.Name = "Prashant"; // Using set accessor
student.Age = 20; // Using set accessor
Console.WriteLine($"Student Name: {student.Name}"); // Using get accessor
Console.WriteLine($"Student Age: {student.Age}"); // Using get accessor
DELEGATE CODE :
using System;
public class Program
// Delegate declaration
public delegate void NotifyDelegate(string message);
// Method that matches the delegate signature
public static void Notify(string message)
Console.WriteLine(message);
public static void Main(string[] args)
// Instantiate the delegate
NotifyDelegate notifyDelegate = new NotifyDelegate(Notify);
// Call the delegate
notifyDelegate("Hello, this is a message using a delegate!");
Console.ReadLine();