Structures, Arrays, Classes... what to use in my case? I'm confused :(

Greetings!

I've advanced a whole LOT on my program now, I got the full client part done in just 3 days o_o... anyhow! as I'm converting my old PureBASIC app to C#, I really loved the way it would use "Structures" to hold "Array data". For example, in PB I could do...

Structure Info
User.s ; String
Warnings.l ; Long integer
EndStructure
Dim UserInfo.Info(2000)

And for accessing/writing I could do, for example:

UserInfo(8)\User="John"

Basically an array with multiple data types inside. Now I've been searching around the net and found a "dilemma" about classes vs structures... I don't care much if those are in the "heap" (something I don't even understand yet :P I'm self-taught) or outside it, but I'd really like to know if there's some way to simulate that with C#. A linked list would be even better (so I wouldn't have to occupy the memory with unused space, but that it increments size as it grows bigger) but I don't know how to do one yet.

My question is... is there a way to archieve a similar "effect" ? and if so, how? I just want to have a plain array that can hold multiple data types as shown there, and being able to edit/add/remove them in runtime... it is possible? I haven't found a "practical" example yet so any help would really come in handy.

Thanks in advance!

[1581 byte] By [DARKGuy] at [2007-12-25]
# 1
Uhm... I hate to bump but I can't believe something like this isn't possible in C# right?
DARKGuy at 2007-9-3 > top of Msdn Tech,Visual Studio Express Editions,Visual C# 2005 Express Edition...
# 2
public partial class Form1 : Form {
private struct Info {
public string User;
public int Warnings;
}
Info[] UserInfo = new Info[2000];

public Form1() {
InitializeComponent();
UserInfo[0].User = "nobugz";
UserInfo[0].Warnings = 666;
}

nobugz at 2007-9-3 > top of Msdn Tech,Visual Studio Express Editions,Visual C# 2005 Express Edition...
# 3
Have you tried something like this?

public struct Info
{
public string Users;
public long Warnings;
}

static void Main(string[] args)
{
Info[] userInfo = new Info[200];

userInfo[0].Users = "Tom";
userInfo[0].Warnings = 123;
userInfo[1].Users = "Dick";
userInfo[1].Warnings = 456;
userInfo[2].Users = "Harry";
userInfo[2].Warnings = 789;

for (int j = 0; j < 3; j++)
{
Console.WriteLine("User {0} Warnings {1}", userInfo[j].Users, userInfo[j].Warnings);
}

}

jrboddie at 2007-9-3 > top of Msdn Tech,Visual Studio Express Editions,Visual C# 2005 Express Edition...
# 4
Also, if you want to store the structure in an array without having to pre-declare its size, you can use an ArrayList from the System.Collections namespace thus:

public struct Info
{
public string user;
public int warning;
}
static void Main(string[] args)
{
ArrayList userInfo = new ArrayList();
Info myInfo = new Info();

myInfo.user = "Jim";
myInfo.warning = 123;
userInfo.Add(myInfo);

myInfo.user = "Tom";
myInfo.warning = 140;
userInfo.Add(myInfo);

myInfo.user = "John";
myInfo.warning = 155;
userInfo.Add(myInfo);

foreach (Info myData in userInfo)
{
Console.WriteLine("User = {0} Warning = {1}",myData.user, myData.warning.ToString());
}


}
jrboddie at 2007-9-3 > top of Msdn Tech,Visual Studio Express Editions,Visual C# 2005 Express Edition...
# 5
Awesome! plainly AWESOME! you two guys ROCK! exactly what I've been searching for! ^_^ omg, like big THANKS this helped me lots throughout this day, now my chat program scripts are working perfectly ^_^... I'll take that into account jrboddie ^^ I've been thinking in that too but I was planning to ask here again when I checked everything was going good before making all the arrays with undefinded size, thanks for clarifying that up for me too awesome guys, great thanks, keep it up! ^_^ :-D
DARKGuy at 2007-9-3 > top of Msdn Tech,Visual Studio Express Editions,Visual C# 2005 Express Edition...