J
jp2msft
I'm pulling records from or database by dates, and there are multiple records
for each part number.
The part numbers are being stored as strings in a List in a custom Employee
class:
List<string> Parts = new List<string>();
If a part number is not already in the list, a new entry is created for an
employee that gets credited this part number:
foreach (EmployeeRecord emp in Employee) {
if (emp.Parts.Contains(strPartNum) == false) {
emp.Parts.Add(strPartNum);
emp.TotalParts += 1;
}
}
This seems very efficient to me.
Now, I have been asked to modify my collection to include the Date that this
part number was recorded.
Does anyone know of a good way to do this?
I've considered using a Dictionary entry using a part number as the key and
the data as the value (or vice versa), but I don't know enough about how to
use these Dictionary entries in a way that is not an actual dictionary.
I tried creating a special class to hold a part number and a date, then
adding that to my List, but then there does not seem to be a way to parse the
List to see if a part number has already been added.
I'm working with Visual Studio 2005 (.NET Framework 2.0).
What other techniques are there that I could look into? Are there better
(i.e. faster) techniques? I don't mind writing more code, but I do to go
through the data quickly.
for each part number.
The part numbers are being stored as strings in a List in a custom Employee
class:
List<string> Parts = new List<string>();
If a part number is not already in the list, a new entry is created for an
employee that gets credited this part number:
foreach (EmployeeRecord emp in Employee) {
if (emp.Parts.Contains(strPartNum) == false) {
emp.Parts.Add(strPartNum);
emp.TotalParts += 1;
}
}
This seems very efficient to me.
Now, I have been asked to modify my collection to include the Date that this
part number was recorded.
Does anyone know of a good way to do this?
I've considered using a Dictionary entry using a part number as the key and
the data as the value (or vice versa), but I don't know enough about how to
use these Dictionary entries in a way that is not an actual dictionary.
I tried creating a special class to hold a part number and a date, then
adding that to my List, but then there does not seem to be a way to parse the
List to see if a part number has already been added.
I'm working with Visual Studio 2005 (.NET Framework 2.0).
What other techniques are there that I could look into? Are there better
(i.e. faster) techniques? I don't mind writing more code, but I do to go
through the data quickly.