Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone.
Recently i've encountered with such problem:
Using recursion,my console app iterating through all node in xml document , validate some types, values and display appropriate message on to console.
Issue lay in next: some times few messages appears in identical format(have identical values and types), how can i get previously written line to console(string representation), for futher comparing with newly generated line , to exclude duplicating??
Posted
Updated 28-Jun-12 21:37pm
v2

1 solution

Simple: write the lines somewhere else in parallel in some container, and compare with data in this container. If you need only limited depth of the stored data and want to avoid using too much memory, you can use it like in a closed-loop video recording. For this purpose, use System.Collections.Generic.Queue<string>: enqueue lines, keep only few in the queue and dequeue them one by one as you output lines, keeping fixed number of lines in the container.

—SA
 
Share this answer
 
Comments
Oleksandr Kulchytskyi 29-Jun-12 9:28am    
Thanks for your reply.
I also look forward for similar solution of using some kind of collection , where i could store entered data and check for duplication.
But also i'm interesting other solution, for example of using native WinApi(P/Invoke), which can help handle last entered line to console)
But anyway, thank for your time)
Sergey Alexandrovich Kryukov 29-Jun-12 13:56pm    
You are welcome.

P/Invoke without a really compelling reason (which you don't have there) is always bad. I hope you know that many of your .NET applications, if written accurately, can be executed on many systems (including Linux, Mac OS X, iOS and more) without re-compilation, at this time, mostly on Mono. By P/Invoke, you break that wonderful compatibility.

You should also think about the idea that you probably pushing the limits of a simple console application and thing about the graphical UI.

--SA
Oleksandr Kulchytskyi 29-Jun-12 14:41pm    
Yep, i didn't think about breaking capabilities of .NET interoperability in differ OS. Again, thanks =)
Sergey Alexandrovich Kryukov 29-Jun-12 17:47pm    
Sure.
Good luck, call again.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900