Here is an example of what I want to create:
A class called Cars
public class Cars
{
public string Mazda;
public string Ford;
etc, etc..........
}
then I want to create properties for each car so if I instantiate Cars:
Cars myCar = new Cars();
then I can access this:
myCar.Mazda.Wheels = Color.Black
I hope this makes sense.
Thanks
PS. I want to randomly pick a car and have its Wheel property checked. 4 1355
What you're talking about is class inheritance.
something like:
public class Cars
{
public System.Drawing.Color Wheels;
}
public class Mazda : Cars
{
}
public class Ford : Cars
{
}
Imran.
"mb" <mm@hotmail.com> wrote in message
news:uh*************@TK2MSFTNGP12.phx.gbl... Here is an example of what I want to create:
A class called Cars
public class Cars { public string Mazda; public string Ford; etc, etc.......... }
then I want to create properties for each car so if I instantiate Cars:
Cars myCar = new Cars();
then I can access this:
myCar.Mazda.Wheels = Color.Black
I hope this makes sense.
Thanks
PS. I want to randomly pick a car and have its Wheel property checked.
Thanks,
I see how that would work, yet I would have to individually instanciate
every car if I awas to use them all.
I want to just instaniate a Car, pick the car I want from the list of
properties, then pick a property of a property. Is this not possible?
"Imran Koradia" <no****@microsoft.com> wrote in message
news:ut**************@TK2MSFTNGP12.phx.gbl... What you're talking about is class inheritance. something like:
public class Cars { public System.Drawing.Color Wheels; }
public class Mazda : Cars {
}
public class Ford : Cars {
}
Imran.
"mb" <mm@hotmail.com> wrote in message news:uh*************@TK2MSFTNGP12.phx.gbl... Here is an example of what I want to create:
A class called Cars
public class Cars { public string Mazda; public string Ford; etc, etc.......... }
then I want to create properties for each car so if I instantiate Cars:
Cars myCar = new Cars();
then I can access this:
myCar.Mazda.Wheels = Color.Black
I hope this makes sense.
Thanks
PS. I want to randomly pick a car and have its Wheel property checked.
MB, I see how that would work, yet I would have to individually instanciate every car if I awas to use them all. I want to just instaniate a Car, pick the car I want from the list of properties, then pick a property of a property. Is this not possible?
In a general way answered, the answer is "No, this is possible" but than you
should create a property "brand" and pass that in your New constructor.
Did you know that for language questions about C# is the very active
newsgroup.
Microsoft.public.dotnet.languages.csharp
I hope this helps?
Cor
"mb" <mm@hotmail.com>
... Thanks,
I see how that would work, yet I would have to individually instanciate every car if I awas to use them all. I want to just instaniate a Car, pick the car I want from the list of properties, then pick a property of a property. Is this not possible?
"Imran Koradia" <no****@microsoft.com> wrote in message news:ut**************@TK2MSFTNGP12.phx.gbl... What you're talking about is class inheritance. something like:
public class Cars { public System.Drawing.Color Wheels; }
public class Mazda : Cars {
}
public class Ford : Cars {
}
Imran.
"mb" <mm@hotmail.com> wrote in message news:uh*************@TK2MSFTNGP12.phx.gbl... > Here is an example of what I want to create: > > A class called Cars > > public class Cars > { > public string Mazda; > public string Ford; > etc, etc.......... > } > > then I want to create properties for each car so if I instantiate Cars: > > Cars myCar = new Cars(); > > then I can access this: > > myCar.Mazda.Wheels = Color.Black > > I hope this makes sense. > > Thanks > > PS. I want to randomly pick a car and have its Wheel property checked. > >
MB,
I believe the way is:
1. Create a car collection or hashtable and use car name as index.
2. Add the cars you need.
3. Use the syntax like
mycars["Mazda"] = Color.Black or
mycars[CarType.Mazda] = Color.Black
Yang Lu.
"mb" wrote: Thanks,
I see how that would work, yet I would have to individually instanciate every car if I awas to use them all. I want to just instaniate a Car, pick the car I want from the list of properties, then pick a property of a property. Is this not possible?
"Imran Koradia" <no****@microsoft.com> wrote in message news:ut**************@TK2MSFTNGP12.phx.gbl... What you're talking about is class inheritance. something like:
public class Cars { public System.Drawing.Color Wheels; }
public class Mazda : Cars {
}
public class Ford : Cars {
}
Imran.
"mb" <mm@hotmail.com> wrote in message news:uh*************@TK2MSFTNGP12.phx.gbl... Here is an example of what I want to create:
A class called Cars
public class Cars { public string Mazda; public string Ford; etc, etc.......... }
then I want to create properties for each car so if I instantiate Cars:
Cars myCar = new Cars();
then I can access this:
myCar.Mazda.Wheels = Color.Black
I hope this makes sense.
Thanks
PS. I want to randomly pick a car and have its Wheel property checked.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Migrant |
last post by:
Hi Friends;
I want develop a group logic with C# (n tier refraction).I know I must
create a Class and inherit it But I don't have enough know-how about develop
classes. Somebody can help me?
...
|
by: mb |
last post by:
what is the best way to do this:
In a game I want to a class called "Items". This class will have the game
items
public class Items
{
public int Chair
public int Table
. . .and so on . . .
|
by: Peter |
last post by:
I want to create a multidemensional arraylist. Seeing as they don't
exist I was wondering if there is a way to create a class that works
like one.
I basically want to use it like this
Dim...
|
by: David A. Osborn |
last post by:
I have a set of classes that each have an enumeration in them, and based on
dynamic input I need to access a different enumeration. For example
Three classes Class_A, Class_B, and Class_C that...
|
by: mb |
last post by:
Here is an example of what I want to create:
A class called Cars
public class Cars
{
public string Mazda;
public string Ford;
etc, etc..........
}
|
by: drk.kumar |
last post by:
I have an implementation issue with WMI scripts to check the user
machine processor. The implementation is working fine in the local
machine (Windows XP operating system). It is throwing script...
|
by: sandy |
last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory',
within my class Directory (Can you already smell disaster?)
Each Directory can have subdirectories so I thought to put these...
|
by: Steve Richter |
last post by:
when enumerating thru the properties of a type, how do I select only
the properties of the derived class? In the example below, the
AddrBookPrompt class is derived from the Form class. When I...
|
by: 100grand |
last post by:
Modify the Inventory Program to use a GUI. The GUI should display the information one
product at a time, including the item number, the name of the product, the number of
units in stock, the price...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |