I want to write a List
on my own.
So I have a class List
and a class ListItem
.
What I now want to do is to create differente classes, for example the class car
. I would like to deduce the class car
from the class ListItem so that I can create a List
of cars.
Now the Class List
shall have different methodes like the one C# gives you.
I wrote an Add and a Count methode and both work.
Here comes the tricky part... I want to write a Funktion to Find an Item in the List. The problem is that I can´t just compare them because 1. I don´t know what the Objekt will look like and what members it will have.
2. I don´t want to compare the characteristics of the class ListItem because they aren´t relevant to the real Object, they are just relevant for the List.
My Idea is, to Create a List Class for each object so in my example it would be a carList
which is deduced from the List Class. This way I could write a Methode that would know what to compare because it would know the ListItem Object. Now I don´t want to create a list class for every Object I want to have a list of. There must be a different way sice c# also gives you the same list class.
Can anyone help?