dynamic arrays..//coming from Delphi

  • Thread starter Thread starter genc ymeri
  • Start date Start date
G

genc ymeri

Hi,
What can I use in C# for dynamic arrays ???? I have some records (struts in
..Net) and want to store them in a dynamic "arrays" or object list.

I noticed the in C# arrays' length can't be extented in run time. So, what
should I use ?

Thank You in advance.

PS:
In Delphi/Pascal I would do something like :

type
aEmployee = record
Name : string;
LastName : String;
DOB :TDatetime;
end;

var
OurListOfEmployees : array of aEmployee;
 
You can use an ArrayList. Or you can write your own array extending
(allocate new array, copy old items over).

-mike
MVP
 
genc said:
// coming from Delphi
There are quite a lot of us here... said:
What can I use in C# for dynamic arrays ???? I have some records (struts in
.Net) and want to store them in a dynamic "arrays" or object list.

struct aEmployee
{
public string Name;
public string LastName;
public DateTime DOB;
}

....
....

ArrayList ourListOfEmployees = new ArrayList();

aEmployee emp;

emp = new aEmployee();
emp.Name = "Dejan";
ourListOfEmployees.Add(emp);

emp = new aEmployee();
emp.Name = "Genc";
ourListOfEmployees.Add(emp);

....
etc
....


LP,
Dejan
 
DC said:
struct aEmployee
{
public string Name;
public string LastName;
public DateTime DOB;
}

I'd advise using a class here, otherwise when you unbox from the ArrayList,
you'll have to reinsert the object or your updates won't be maintained.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

How to convert Delphi Record to C#? 0
converting delphi code to c# 4
Array 3
dynamic length arrays 10
Dynamics Array adding an object 4
Dynamic array 1
Delphi type events in C# 16
Delphi PChar and C# 1

Back
Top