Further to solution 1 and the comments.
1. You've been beaten up a bit about this hard coded data - I'm going to generously assume that it's just a quick way of knocking up some test data to demonstrate your problem. So some advice - tuck that away in methods in a repository layer, call them something like FetchShippingItems and FetchPendingItems and have a //TODO comment in there that says something like "Hard-coded test data for now"
2. _Asif_ in Solution 1 has alluded to your real problem - you are not "tying together" the two bits of data. Unfortunately most of that solution is dealing with the fact you had hard-coded data - but you could use that within your repository layer.
3. The key points that _Asif_ has mentioned are
Class
,
Dictionary
and
KeyValuePair
Taking the Class first - this could hold everything you need to know about a Shipping item and a way to construct one e.g.(deliberately light-weight example)
class ShippingItem
{
public string Carrier { get; set; }
public int Shipped { get; set; }
public int Pending { get; set; }
public ShippingItem(string carrier, int shipped, int pending)
{
Carrier = carrier;
Shipped = shipped;
Pending = pending;
}
}
and your repository could populate a collection with instances of that class e.g.
var Shipping = new List<shippingitem>();
Shipping.Add(new ShippingItem("Fedex", 234, 0));
But you are then going to have dive into each item to work out the number that are being shipped and the number that are pending - which probably isn't the best idea for your bar chart, and you may also end up carrying around all that extra information about shipping items when really all you want to know is how many are shipping and how many are pending.
So how about using KeyValuePair? A list of these will do exactly what you need - keep a name and a number tightly together.
For example (and still using your hard-coded test data) that repository method
FetchShippingItems
could return a List of KeyValuePair ...
var Shipping_List = new List<KeyValuePair<string, int>>();
Shipping_List.Add(new KeyValuePair<string,int>("Fedex",234));
Shipping_List.Add(new KeyValuePair<string,int>("UPS",32));
var Pending_List = new List<keyvaluepair><string,>>();
Pending_List.Add(new KeyValuePair<string,>("R&L", 2));
Pending_List.Add(new KeyValuePair<string,int>("UPS",2));
A Dictionary would work the same way ...
var Shipping_List = new Dictionary<string, int>();
Shipping_List.Add("Fedex", 234);
The real key points to take away from all of this ...
A) Using two (or more) Lists (or Arrays, or any collection) to hold bits of information about the same thing is rarely (if ever) a good idea. It's just too easy for things to get out of step and if you want another piece of information you have to introduce a whole new List (or Array, or collection)
Get comfortable with ways of grouping things together - when is a class appropriate or just a KeyValuePair or a combination etc etc.
B) Get to know what collections are available
starting here[
^]. Choose the one that is most appropriate for your need at the time (in other words, don't fixate on a single collection - get to know them all)