开发者

Ways of reading txt file contents into forms?

开发者 https://www.devze.com 2023-01-27 06:03 出处:网络
At work we have a txt file with items recorded in them The columns are typical of Apple,*fruit Cow,*animal

At work we have a txt file with items recorded in them

The columns are typical of

Apple,  *fruit
Cow,    *animal
House,  *thing
Tree,   *plant

Is it possible too read through this txt f开发者_StackOverflow中文版ile to check if apple already exists. I namely want to build a preventative for adding double items...


I think you have to read the file in to a list of objects. In this case, the object will get 2 properties: Type and Category.

After that you can easily perform comparisons etc on the list itself.

Edit: Some stuff for you to read; Reading a file: http://msdn.microsoft.com/en-us/library/system.io.streamreader.readline.aspx

Dictionary: http://msdn.microsoft.com/en-us/library/xfhwa508.aspx

I'm unable to write down an example now, but those are the ingredients.

0

精彩评论

暂无评论...
验证码 换一张
取 消