Skip to main content
Code Review

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

Is it possible to put the array name into a variable and iterate by a foreach loop?

YES.

Array ProductItems = Drinks.ToArray();
foreach(Product item in ProductItems)
 {
 Console.WriteLine(item.ProductName);
 } 

Now about your second question, (it's unclear what's the significance of the first question)...

If there are many products and user selects one from the combobox1 how to update the product details in listbox1? (is this your question?)

Answer : Make a Dictionary of combobox1 index and ProductList. Iterate over the combobox1 list and map the indexes with the ProductList. This may help This may help.

Dictionary ProductDict = new Dictionary<int, List<Product>>(); 

Then after SelectedIndexChanged event is fired get the ProductList corresponding with combobox1 index. Then iterate over the list and add the details it in listbox.


General Review

Since productName and price is trivial make them auto-implemented properties

public string ProductName { get; set; }

Is it possible to put the array name into a variable and iterate by a foreach loop?

YES.

Array ProductItems = Drinks.ToArray();
foreach(Product item in ProductItems)
 {
 Console.WriteLine(item.ProductName);
 } 

Now about your second question, (it's unclear what's the significance of the first question)...

If there are many products and user selects one from the combobox1 how to update the product details in listbox1? (is this your question?)

Answer : Make a Dictionary of combobox1 index and ProductList. Iterate over the combobox1 list and map the indexes with the ProductList. This may help.

Dictionary ProductDict = new Dictionary<int, List<Product>>(); 

Then after SelectedIndexChanged event is fired get the ProductList corresponding with combobox1 index. Then iterate over the list and add the details it in listbox.


General Review

Since productName and price is trivial make them auto-implemented properties

public string ProductName { get; set; }

Is it possible to put the array name into a variable and iterate by a foreach loop?

YES.

Array ProductItems = Drinks.ToArray();
foreach(Product item in ProductItems)
 {
 Console.WriteLine(item.ProductName);
 } 

Now about your second question, (it's unclear what's the significance of the first question)...

If there are many products and user selects one from the combobox1 how to update the product details in listbox1? (is this your question?)

Answer : Make a Dictionary of combobox1 index and ProductList. Iterate over the combobox1 list and map the indexes with the ProductList. This may help.

Dictionary ProductDict = new Dictionary<int, List<Product>>(); 

Then after SelectedIndexChanged event is fired get the ProductList corresponding with combobox1 index. Then iterate over the list and add the details it in listbox.


General Review

Since productName and price is trivial make them auto-implemented properties

public string ProductName { get; set; }
fixed explanation.
Source Link

Is it possible to put the array name into a variable and iterate by a foreach loop?

YES.

Array ProductItems = Drinks.ToArray();
foreach(Product item in ProductItems)
 {
 Console.WriteLine(item.ProductName);
 } 

Now about your second question, (it's unclear what's the significance of the first question)...

If there are many products and user selectselects one from comboboxthe combobox1 how to update the product details in listboxlistbox1? (is this your question?)

Answer : Make a DictionaryDictionary ofcombobox1 index and product listProductList. Iterate over the comboboxcombobox1 list and map the indicesindexes with the product listProductList. This may help.

Dictionary ProductDict = new Dictionary<int, List<Product>>(); 

Then after SelectedIndexChanged event is fired get the corresponding ProductList corresponding with respect to combobox1 index. Then iterate over the product list and add the details it in listbox.


General Review

Since productName and price is trivial make them auto-implemented properties

public string ProductName { get; set; }

Is it possible to put the array name into a variable and iterate by a foreach loop?

YES.

Array ProductItems = Drinks.ToArray();
foreach(Product item in ProductItems)
 {
 Console.WriteLine(item.ProductName);
 } 

Now about your second question, (it's unclear what's the significance of the first question)...

If there are many products and user select one from combobox how to update the product details in listbox? (is this your question?)

Answer : Make a Dictionary of index and product list. Iterate over the combobox list and map the indices with the product list. This may help.

Dictionary ProductDict = new Dictionary<int, List<Product>>(); 

Then after SelectedIndexChanged event is fired get the corresponding ProductList with respect to combobox1 index. Then iterate the product list and add it in listbox.


General Review

Since productName and price is trivial make them auto-implemented properties

public string ProductName { get; set; }

Is it possible to put the array name into a variable and iterate by a foreach loop?

YES.

Array ProductItems = Drinks.ToArray();
foreach(Product item in ProductItems)
 {
 Console.WriteLine(item.ProductName);
 } 

Now about your second question, (it's unclear what's the significance of the first question)...

If there are many products and user selects one from the combobox1 how to update the product details in listbox1? (is this your question?)

Answer : Make a Dictionary ofcombobox1 index and ProductList. Iterate over the combobox1 list and map the indexes with the ProductList. This may help.

Dictionary ProductDict = new Dictionary<int, List<Product>>(); 

Then after SelectedIndexChanged event is fired get the ProductList corresponding with combobox1 index. Then iterate over the list and add the details it in listbox.


General Review

Since productName and price is trivial make them auto-implemented properties

public string ProductName { get; set; }
fixed explanation.
Source Link

Is it possible to put the array name into a variable and iterate by a foreach loop?

YES.

Array ProductItems = Drinks.ToArray();
foreach(Product item in ProductItems)
 {
 Console.WriteLine(item.ProductName);
 } 

Now about your second question, (it's unclear what's the significance of the first question)...

If there are many products and user select one from combobox how to update the product details in listbox? (is this your question?)

Answer : Make a Dictionary of index and product list. Iterate over the combobox list and map the indices with the product list. This may help.

Dictionary ProductDict = new Dictionary<int, List<Product>>(); 

Then after SelectedIndexChanged event is fired you can get the corresponding Product ListProductList correspondingwith respect to the combobox1 index. Then iterate the product list and add it in listbox.


General Review

Since productName and price is trivial make them auto-implemented properties

public string ProductName { get; set; }

Is it possible to put the array name into a variable and iterate by a foreach loop?

YES.

Array ProductItems = Drinks.ToArray();
foreach(Product item in ProductItems)
 {
 Console.WriteLine(item.ProductName);
 } 

Now about your second question, (it's unclear what's the significance of the first question)...

If there are many products and user select one from combobox how to update the product details in listbox? (is this your question?)

Answer : Make a Dictionary of index and product list. Iterate over the combobox list and map the indices with the product list. This may help.

Dictionary ProductDict = new Dictionary<int, List<Product>>(); 

Then after SelectedIndexChanged is fired you can get the Product List corresponding to the combobox1 index. Then iterate the product list and add it in listbox.


General Review

Since productName and price is trivial make them auto-implemented properties

public string ProductName { get; set; }

Is it possible to put the array name into a variable and iterate by a foreach loop?

YES.

Array ProductItems = Drinks.ToArray();
foreach(Product item in ProductItems)
 {
 Console.WriteLine(item.ProductName);
 } 

Now about your second question, (it's unclear what's the significance of the first question)...

If there are many products and user select one from combobox how to update the product details in listbox? (is this your question?)

Answer : Make a Dictionary of index and product list. Iterate over the combobox list and map the indices with the product list. This may help.

Dictionary ProductDict = new Dictionary<int, List<Product>>(); 

Then after SelectedIndexChanged event is fired get the corresponding ProductList with respect to combobox1 index. Then iterate the product list and add it in listbox.


General Review

Since productName and price is trivial make them auto-implemented properties

public string ProductName { get; set; }
Source Link
Loading
lang-cs

AltStyle によって変換されたページ (->オリジナル) /