I am a total c#-noob and have a little question. I'll try to put it in an example:
I have a class "Car" that has the fields "name" and wheels.
Wheels are from the type "Wheel".
The constructor of the Car-Class sets the name of the car-objekt and the id of the Wheel-Object.
Expect now, there are more cars, each with its wheels.
Now I want to do something like "getCarByWheel_id()":
All I have is the ID of one wheel and i want to get the object of the corresponding car.
You know what i mean?
Expand|Select|Wrap|Line Numbers
- class Car{
- string name;
- public Wheel Wheels;
- public Car(string name, int wheel_id){
- this.name="mycar";
- this.Wheels = new Wheel();
- this.Wheels.Id= 1234;
- }
- }
- class Wheel{
- public int Id;
- public Wheel() { }
- }
Greetings from germany,
Günther