Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
11 views4 pages

Prashant Dhiman Assignment

The document is an assignment from the THDC Institute of Hydropower Engineering and Technology, focusing on .NET Framework and C#. It includes code examples for a Student class demonstrating properties and a delegate for notification messages. The assignment is submitted by Prashant Dhiman to Mr. Ravindra Rawat in the Computer Science and Engineering department.

Uploaded by

ak20ee02
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views4 pages

Prashant Dhiman Assignment

The document is an assignment from the THDC Institute of Hydropower Engineering and Technology, focusing on .NET Framework and C#. It includes code examples for a Student class demonstrating properties and a delegate for notification messages. The assignment is submitted by Prashant Dhiman to Mr. Ravindra Rawat in the Computer Science and Engineering department.

Uploaded by

ak20ee02
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

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();

You might also like