如何在设置文件中保存对象列表?

问题描述:

我想在 C# Winform 的设置文件"中保存对象列表.我可以使用列表字典,但它是一对(键,值)列表.如何在资源文件中保存列表或集合 (IEnumberable)?

I Want to save a list of objects in 'setting file' in C# Winform. I can use List Dictionary but its a pair (key,value) list. How can I save a list or collection (IEnumberable) in Resource file?

您可以搜索其他集合,您不限于显示的内容,我知道的唯一限制是使用通用集合.你总是可以使用 ArrayList 或者有一个 StringCollection 可用.您可以通过单击浏览然后导航到 mscorlib --> 来访问它们.System.Collections -->ArrayListSystem -->System.Collections.Specialized -->字符串集合.但由于您需要一个对象,我可能会使用 ArrayList 因为在这种情况下,泛型似乎不是一个选项.

You can can do a search for additional collections, you are not limited to what is shown the only limitations that I know of is the use of a generic collection. You can always use an ArrayList or there is a StringCollection available. You can get to them by clicking the browse then navigating to mscorlib --> System.Collections --> ArrayList or System --> System.Collections.Specialized --> StringCollection. But since you are needing an object I would probably use the ArrayList since it appears that Generics are not an option in this situation.