Reading 2 files C# loops

Hi,

I am trying to read 2 files both tab separated and the first string value before first tabs needed to be checked and if the keys are matching, i need to parse the last value in a line of the file.

I managed reading those files, by inner loop and when i find the key in the inner loop, i am returning a bool.

Is this the correct approach?

Br.
LVL 12
jazzIIIloveAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Miguel OzSoftware EngineerCommented:
It seems correct but it depends on the file size.
For example if your file size > 200 MB it will consume memory if you keep the file contents until the program finishes execution. (Yep still some business shops use 4 GB RAM PCs)
Alexei KuznetsovMicrosoft Outlook MVPCommented:
I recommend you to perform basic indexing before working with your files. Some explanations:

1. Read the first file line by line and fill the Dictionary<string, int> dic1; where string is the key and int is the position in your file1. Or just <string, string> if the memory is not an issue (second string is the entire line).
2. Read the second file line by line and for each line line try to get the key from dic1. If found, you have lines from both files here. If not, there are no such key in file1.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.