How to use the object type correctly

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I wonder if someone could tell me how to do what i am trying. Basically
I have a class pointed to by an object type variable which will point
to a class to be set at runtime. I want to call methods from the class
that the object var is pointing to but dont know how to go about it.

Cheers
Gary

using System;

namespace carsCarsCars
{
class MainClass
{
public static void Main(string[] args)
{
Console.WriteLine("Hello World!");
Toyota xyz794 = new Toyota();
Toyota xyz795 = new Toyota();
Nissan ttt214 = new Nissan();
Toyota tyz794 = new Toyota();

Person George = new Person("George", xyz794, xyz795);
Person Albert = new Person("Albert", ttt214, tyz794);
// -----------------------------------------------------
// George.carOne.printMake(); // this line doesnt compile
// ------------------------------------------------------
}
}
public class Person
{
string name;
public object carOne = new object();
public object carTwo = new object();
public Person(string theName, object theCarOne, object theCarTwo)
{
name = theName;
carOne = theCarOne;
carTwo = theCarTwo;
}
}
class Car
{
public int numberOfWheels=4;
}
class Toyota : Car
{
public void printMake() {
Console.WriteLine("toyota");
}
}
class Nissan : Car
{
public void printMake() {
Console.WriteLine("nissan");
}
}

}

.



Relevant Pages

  • link list question
    ... now i dont know head pointer. ... I know only the pointer which is pointing ... Prev by Date: ...
    (comp.lang.c)
  • copy error
    ... each time through loop ... It also returns a '1' which I dont not understand since it ... Shouldnt it be '0'? ... Prev by Date: ...
    (comp.lang.perl.misc)
  • Re: Macro for single to multiple cols. Help!
    ... Dont understand... ... dfkelly42's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=12094 ... Prev by Date: ...
    (microsoft.public.excel.newusers)
  • Re: Ferret 0.2.1 (port of Apache Lucene to pure ruby)
    ... i dont see a result (with some i ... seems to reliably return the expected matches. ... (running ruby 1.8.2 on OS X 10.3.8) ... Prev by Date: ...
    (comp.lang.ruby)
  • Re: What it is that The British Left Finally Starts to Understand
    ... > Baha'is like you dont want to visit after you have departed from this ... It is amazing George, that you were a Baha'i so long and learned ... That passage had nothing to do with CBs. ... Baha'u'llah was pointing to the apocalypic prophecies of the Judgement ...
    (talk.religion.bahai)