Array of classes

  • Thread starter Thread starter Chad Z. Hower aka Kudzu
  • Start date Start date
Abubakar said:
Can u write a little delphi code to do what u r saying ?

I've solved it with Jon's help. Did you want the Delphi code just for
curiosity? If so I can write it.
 
Hi Chad,
Thanks. Is there any way to declare a type of my base class? Or is type
generic only? That is in Delphi I can do:

type
TMyClassType = class of TMyClass;

No, C# (and .NET as a platform)doesn't support the concept of meta classes
as Delphi does. Eventhough sometimes you can think of .NET Type objects as
Delphi meta classes this could be correct in some very-very few situations.
And because you don't have the Delphi concept of meta classes you don't have
virtual constructors and virtual static members.

B\rgds
100
 
Abubakar said:
[...] Did you want the Delphi code just for
curiosity? If so I can write it.
yes for my own learning I want to look at how its done in delphi. Thanx
:-)

This is just in the newsreader, so it might not compile but here is the
basic idea:

type
TFoo = class(TObject)
...
...
...
end;

TFoo1 = class(TFoo)
...
...
...
end;

TFoo2 = class(TFoo)
...
...
...
end;

TFooClass = class of TFoo;

Now I can make an array:

var
MyFoos: Array[0..1] of TFoo = (TFoo1, TFoo2);

Then later I can do

var
LFoo: TFoo;
begin
LFoo := MyFoos[0].Create;

Make sense? Its a lot cleaner in Delphi. :)
 
I did not and still do not understand your requirement despite reading
almost all the posts. But I will venture to give the following
suggestion

1. Create a class indexer
public class myIndexer
{
object[] o=new object[12];
public object this[int index]
{
get
{
return o[index];
}
set
{
o[index]=value;
}
}
}

2.
Assign the form1,form2 objects to the above class
myIndexer ob=new myIndexer();

ob[0]=form1;
ob[1]=form2;

3.

Convert them to form objects with

form1=(Form)ob[0];

etc.

I hope the above is what you have been looking for.

with regards,


J.V.Ravichandran
- http://www.geocities.com/
jvravichandran
- http://www.411asp.net/func/search?
qry=Ravichandran+J.V.&cob=aspnetpro
- http://www.southasianoutlook.com
- http://www.MSDNAA.Net
- http://www.csharphelp.com
- http://www.poetry.com/Publications/
display.asp?ID=P3966388&BN=999&PN=2
- Or, just search on "J.V.Ravichandran"
at http://www.Google.com
 
Back
Top