I want to have two arrays:
so i want for example to have :
[12,13,53,165,76] that are the IDs of the suppliers and
supplierList[12] the clientList of the supplier 12.
I tried with that:
public void calculateMetrics (MDG graph)
{
ArrayList supplierList = new ArrayList();
ArrayList clientList = new ArrayList();
foreach (EA.Package package in modelRepository.Models)
{
foreach (EA.Package pack in package.Packages)
{
foreach (EA.Connector link in pack.Connectors)
{
int supplier = link.SupplierID;
int client = link.ClientID;
for(int i=0; i<supplierList.Count; i++)
{
if (supplier.Equals(supplierList[i]))
{
**((ArrayList)clientList((ArrayList)supplierList[i]).Add(client);**
supplierList.Add(clientList);
But without a surprise it doesn't work, but i don't know how to do it.
Why not create a Supplier Object that contains a List of Client IDs as a member variable? This way you are only involving one List to iterate through directly and it will clean up your code.
More specifically:
Supplier object (Class) - Has ID (int), Client (Object)
Client object (Class) - Has ID, perhaps other properties.
Look up the syntax for object creation; you will find in an object-oriented environment, creating objects can really help out!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With