need something like enumerated classes.
-
I need something like an enumeration of classes.
class Garage{ public static Car Ford = new Car (.....); public static Car Chevy = new Car (.....); public static Car Subaru = new Car (.....); public static Car Mazda = new Car (.....); }
then do something likeforeach(Car x in Garage){ ... ... }
Funny thing: By force of habit, I hit F6 after I typed this..;P -
I need something like an enumeration of classes.
class Garage{ public static Car Ford = new Car (.....); public static Car Chevy = new Car (.....); public static Car Subaru = new Car (.....); public static Car Mazda = new Car (.....); }
then do something likeforeach(Car x in Garage){ ... ... }
Funny thing: By force of habit, I hit F6 after I typed this..;PUse a collection. public static Car = nll; ArrayList list = new ArrayList(); Ford = new Car (.....); list.Add(Ford); foreach(Car c in Garage) ....... Mike
If you keep doing what you've been doing you'll keep getting what you've been getting!
-
Use a collection. public static Car = nll; ArrayList list = new ArrayList(); Ford = new Car (.....); list.Add(Ford); foreach(Car c in Garage) ....... Mike
If you keep doing what you've been doing you'll keep getting what you've been getting!
Mike Hankey wrote:
ArrayList list = new ArrayList();
But only in C# 1.1, otherwise, use generic collections.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
I need something like an enumeration of classes.
class Garage{ public static Car Ford = new Car (.....); public static Car Chevy = new Car (.....); public static Car Subaru = new Car (.....); public static Car Mazda = new Car (.....); }
then do something likeforeach(Car x in Garage){ ... ... }
Funny thing: By force of habit, I hit F6 after I typed this..;Pdino2094 wrote:
public static Car Ford = new Car (.....); public static Car Chevy = new Car (.....); public static Car Subaru = new Car (.....); public static Car Mazda = new Car (.....);
Wouldn't it make more sense to have a collection of car types, as derived classes ? Can't you ever have more than one Mazda in your garage ?
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Mike Hankey wrote:
ArrayList list = new ArrayList();
But only in C# 1.1, otherwise, use generic collections.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
Yes..Thank You I'm still converting from VS2002 to VS2005 , its taking awhile? Mike
If you keep doing what you've been doing you'll keep getting what you've been getting!
-
dino2094 wrote:
public static Car Ford = new Car (.....); public static Car Chevy = new Car (.....); public static Car Subaru = new Car (.....); public static Car Mazda = new Car (.....);
Wouldn't it make more sense to have a collection of car types, as derived classes ? Can't you ever have more than one Mazda in your garage ?
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
Christian Graus wrote:
Can't you ever have more than one Mazda in your garage ?
Or even more than one Mazda in all garages (note, he's declared them as
static
)
Upcoming events: * Edinburgh: Web Security Conference Day for Windows Developers (12th April) * Glasgow: Introduction to AJAX (2nd May), SQL Server, Mock Objects My website