473,396 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

C# GetObjectByField_id ?

hallo

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
  1. class Car{
  2.   string name;
  3.   public Wheel Wheels;  
  4.  
  5.   public Car(string name, int wheel_id){
  6.     this.name="mycar";
  7.     this.Wheels = new Wheel();
  8.     this.Wheels.Id= 1234;
  9.   }
  10. }
  11.  
  12. class Wheel{
  13.   public int Id;
  14.  
  15.   public Wheel() { }
  16. }
Thanks a lot for your help and have a nice weekend!
Greetings from germany,

Günther
Dec 14 '07 #1
0 829

Sign in to post your reply or Sign up for a free account.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.