How would you approach this? I have a list of data that has two things that should be stored in price and position, is there anyway to store this in an array, not knowing the total number of rows that I will have? Or should I use a collection if they can be multidimensional?
thank
Yes - I would recommend you look at the general list. Using this, you can simulate your data and store as many elements as possible.
for instance
public class PricedItem { public decimal Price { get; set; } public object Item { get; set; } }
They can then be saved / retrieved to List<PricedItem> - or as a "list of rated items".
List<PricedItem
Hope that helps
, "", , .
, . , , id, name, description, price, ,
Dictionary<int, item> items = new Dictionary<int, item>(); items.add(myitem.id, myitem);
,
string description = items[id].description; decimal price = items[id].price;
List<> - , . , KeyValuePair<>, () (). A List<KeyValuePair<string, string>>, Linq , . , KeyValuePairs, Key, , , .
List<>
KeyValuePair<>
List<KeyValuePair<string, string>>
you may have
struct Item { float Price; string ItemName; }
and
List<Item> items = new List<Item>(); items.Add(new Item{Name="item1", Price=19.99});
Source: https://habr.com/ru/post/1793650/More articles:Is it possible to create a playlist of .m3u8 playlists for the iPhone? - iphoneFind non-integer values in float field - sqlPHP $_SESSION пуст после перенаправления заголовка - redirectCut vision transparency so as not to fix onclick? - androidWhat is the difference between elastic, fluid, fluid, fixed layout in CSS - cssvery strange database query result - phpAzure Diagnostic - how to get raw performance counter data - azureTake the width and height of the device - iphoneRails: removing a user without losing associations (or other ways to allow users) - ruby-on-railsChecking the Specflow / Watin Page - c #All Articles