I have a file containing likes written like this:
[NAME]: [PROPERTY]-[VALUE], [PROPERTY]-[VALUE], [PROPERTY]-[VALUE].
E.g.:
[Person]: [Age]-[21], [HairColor]-[Turqoise], [Gender]-[Other].
While I’m familiar with Linq, I’m having a lot of trouble figuring out how I would parse this, using Linq.
I’d like to be able to just go over all the lines:
[NAME]: [PROPERTY]-[VALUE], [PROPERTY]-[VALUE], [PROPERTY]-[VALUE].
[NAME]: [PROPERTY]-[VALUE], [PROPERTY]-[VALUE], [PROPERTY]-[VALUE].
[NAME]: [PROPERTY]-[VALUE], [PROPERTY]-[VALUE], [PROPERTY]-[VALUE].
[NAME]: [PROPERTY]-[VALUE], [PROPERTY]-[VALUE], [PROPERTY]-[VALUE].
[NAME]: [PROPERTY]-[VALUE], [PROPERTY]-[VALUE], [PROPERTY]-[VALUE].
[NAME]: [PROPERTY]-[VALUE], [PROPERTY]-[VALUE], [PROPERTY]-[VALUE].
[NAME]: [PROPERTY]-[VALUE], [PROPERTY]-[VALUE], [PROPERTY]-[VALUE].
[NAME]: [PROPERTY]-[VALUE], [PROPERTY]-[VALUE], [PROPERTY]-[VALUE].
… And do something with each person retrieved.
Any ideas? Any help at all will be much appreciated.
Here is an example, if I’ve got what you need correctly, of course:
So, here you get a list of anonymous objects with two properties:
In my example I do a simple loop through what I’ve read, printing it into the console
The content of the test file (Utils.txt) was the following:
The output: