C# Dictionary Application: Applying Values through the selection of keys -


I have a dictionary that I am using to define the rating of copper cable. I want to calculate how many cables it will take to complete a certain connection rating to use these values. The connection, cable type, and system type size are chosen by two comboboxes named cb_amperage, cb_cable_size and, cb_system_type. Once the equation is run, the answer displayed in the text box named tb6_cable_qty is. I welcome any and all comments and suggestions Thanks in advance for assistance

Mathematics is easy:

  decimal x, y, z; X = decimal Purse (cb_amperage.); Y = decimal.Parse (); // & LT; ---- This value should come from a = decimal.Parse () dictionary below; // & LT; ---- This value should also come from a dictionary below the Z = (x / y) * a tb6_cable_qty.Text = math.gol (z, 2) .toString (); Cb_amperageSelectedIndexChanged (object sender, EventArgs e) {if (zero!.! String IsNullOrEmpty (cb_amperage) & amp ;! String.IsNullOrEmpty (cb_cable_size)) does not // Sure, right version of it later but I thought it coveys It seems that {// function is based on the values ​​given in the dictionary below // cable volume 1 is used for calculating cable volume & lt; String, int & gt; Cable_dictionary_1 = New Dictionary & lt; String, int & gt; (); Cable_dictionary_1.Add ("# 1", 130); Cable_dictionary_1.Add ("1/0", 150); Cable_dictionary_1.Add ("2/0", 175); Cable_dictionary_1.Add ("3/0", 200); Cable_dictionary_1.Add ("4/0", 230); Cable_dictionary_1.Add ("250", 255); Cable_dictionary_1.Add ("300", 285); Cable_dictionary_1 .ad ("400", 355); Cable_dictionary_1.Add ("500", 380); Cable_dictionary_1.Add ("600", 720); Cable_dictionary_1.Add ("750", 475); // System type used for cable volume calculation & lt; String, int & gt; System_type_dictionary = New Dictionary & lt; String, int & gt; (); System_type_dictionary.Add ("3P 3W", 3); System_type_dictionary.Add ("3P 4W", 4);  

1 Edit: mm; Please take a look at the code below. I came to be a feeling that I missed something, so I will know whether I was a little more elaborate. The following recommendation is that my implementation of the first part of the solution suggested by you is my implementation. I get an error that I think it is because these two items, string and dictionaries do not know they should be linked. Here is an error; * Invalid token ',' class, structure, or interface member declaration (CS1519). See what you can see again thanks again.

  // cable Streting string cblsize1 = "# 1"; The following strings are used in cable quantity calculation; Private cast string cblsize2 = "1/0"; Private cast string cblsize3 = "2/0"; Private cast string cblsize4 = "3/0"; // cable dictionary 1 cable is used for calculating volume & lt; String, int & gt; Cable_dictionary_1 = New Dictionary & lt; String, int & gt; (); Cable_data.ed (cblsize1, 130); // # 1 cable cable director.ed (cblsize2, 150); // 1/0 cable cable_dictionary.Add (cblsize3, 175); // 2/0 cable cable_dictionary.Add (cblsize4, 200); // 3/0 cable  

I'm not sure what your question is? It seems that you got all this cover.


Comments