Can someone help me with C#?

I am halfway through my bachelor in Web Development, and my teacher has told me to seek help online if I have trouble, so I will follow his advice.
I have a C# project for this week, and as a beginner I feel a bit lost.

The requirements for my project is:

Make a Person class.

You decide which information is needed, but name, age and e-mail must be present and the class must have a ChangeEmail method.

Make two subclasses Traindriver and Administrator which inherit Person.

You decide which additional information is needed, but traindrivers need a licence number.

The Administrator must override the ChangeEmail method to check that the email is of type

All classes must have a ToString method.

Make an aspx page where the persons can be created when entering the necessary data.

New persons must be created as objects.

All persons must be placed in an ArrayList or similar.

So far I have created the classes, but I am stuck on the “ChangeEmail method” that I have to make, and how to allow the Administrator to override it.
I have tried finding the answers in my book, but there is no example that I can follow.
I would be so happy if someone could guide me.

Here is the code as it looks now.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Person
    public class Person
        protected string name;
        protected int age;
        protected string email;

        public Person(string name, int age, string email)
   = name;
            this.age = age;
   = email;

        public string Name
            get { return name; }
            set { name = value; }

        public int Age
            get { return age; }
            set { age = value; }

        public string Email
            get { return email; }
            set { email = value; }

        public override string ToString()
            return "Name: " + name + " Age: " + age + " E-Mail: " + email;

    public class Traindriver : Person
        protected int licence;

        public Traindriver(int licence)
            this.licence = licence;

        public int Licence
            get { return licence; }
            set { licence = value; }

    class Administrator : Person
        protected string licence;

Have you written methods before? Your Person class needs a public method called ChangeEmail that assigns a new value to the email value.

Both Traindriver and Administrator will inherit that method, but your assignment requires extra logic for the ChangeEmail method on the Administrator class, so you will need to add that method to the Administrator class definition.

1 Like