简体   繁体   English

如何在C#中存储多个类别

[英]How to store Multiple categories in C#

I'm working on a C# project for a class and my assignment is to make a forms app that looks like the Carvana website.我正在为 class 开发一个 C# 项目,我的任务是制作一个看起来像 Carvana 网站的 forms 应用程序。 For instance, if the user picks Nissan only Nissan cars come up and if you change the body type to trucks only Nissan trucks show up.例如,如果用户选择 Nissan,则只会出现 Nissan 汽车,如果您将车身类型更改为卡车,则只会出现 Nissan 卡车。 Also, each model has additional information about them such as the truck is 4-wheel drive, etc. I was going to use a jagged array, but I don't think that's the best way so I'm kind of stuck.此外,每个 model 都有关于它们的附加信息,例如卡车是四轮驱动等。我打算使用锯齿状阵列,但我认为这不是最好的方法,所以我有点卡住了。 Thank you for any help感谢您的任何帮助

So far I have only used arrays and I tried Enums for the makes and that works for what I wanted to use them for.到目前为止,我只使用了 arrays 并且我尝试了 Enums 作为品牌,这适用于我想要使用它们的目的。 Also I'm using combo boxes for the pull-down menu我还为下拉菜单使用了组合框

You can store your data in an XML or JSON object. Easy to append. Easy to search.您可以将数据存储在XMLJSON object。易于 append。易于搜索。

If you want to stick with something similar you are already using, You better use an object Dictionary .如果你想坚持使用你已经在使用的类似的东西,你最好使用 object Dictionary

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM