Yes, it's possible, but you will eventually mimmick the behavior of a Hash Table (or Dictionary) of of a DataSet and DataTable (the HARD way).
thines01
Postaholic
2,433 posts since Oct 2009
Reputation Points: 447
Solved Threads: 408
Skill Endorsements: 7
I would suggest to create a class for the numbers structure and properties like:
Partial Class NumberAndProperties : IComparer {
public readonly int Key;
public readonly int Property1;
public readonly int Property2,
public readonly int Property3;
void New(int key, int property1, int property2, int property3){
Key = key;
Property1 = property1;
Property2 = property2;
Property3 = property3;
}
int IComparer.Compare(object a, object b){
NumberAndProperties A = (NumberAndProperties) a;
NumberAndProperties B = (NumberAndProperties) b;
If (A.Key > B.Key) return 1;
if (A.Key < B.Key) return -1;
return 0;
}
}
Then use this class for a List<NumberAndProperties> to hold the data. To do that
add
public List<NumberAndProperties> TheNumbers = new List<NumberAndProperties>();
inside the class, before the public void DataBase and change this piece to:
//this part will read the array passed from Form1
//also in this part, as the numbers from the array are being read, there
//respective properties are given to them.
//Somewhat like this,
// if (numbers[i] == "0")
// {
// prop1 = 1;
// prop2 = 2;
// prop3 = 3;
NumberAndProperties newNumberAndProperties = new NumberAndProperties(numbers[i], property1Value, Property2Value, property3value);
TheNumbers.Add(newNumberAndProperties);
// }
Then, to retrieve any value, you can use the List<T> methods and properties, and you'll always get a NumberAndProperties class with the Key and the Property 1 to 3.
Hope this helps
lolafuertes
Practically a Posting Shark
895 posts since Oct 2008
Reputation Points: 164
Solved Threads: 189
Skill Endorsements: 5
I'll try to answer your questions:
1) Where to put the class? I normally create each class in a separate source for that class. Obviously you can add the class in the same source you already have.
2) The IComparer.Compare will permit to sort the list or to verify if a key already exists.
3) The List usage is based on specialized list that will know the class structure, allowing the direct access to any list item key or property.
Hope this helps
lolafuertes
Practically a Posting Shark
895 posts since Oct 2008
Reputation Points: 164
Solved Threads: 189
Skill Endorsements: 5