Here is something neat I found out.
Say you are writing an application and one of the requirements is to allow File System search. You could always start using loops and such. I thought to myself why not do it in LINQ? I played around with it and in fact it is not so hard.
Lets see how it is done. Here is method that allows finding a specific file name in side a directory.
1: private List SearchFilesByName(string DirectoryPath, string FileName)
2: {
3: return (from file in new DirectoryInfo(DirectoryPath).GetFiles()
4: where file.Name == FileName select file).ToList();
5: }
Basically we Query the FileInfo[] which is returned from the GetFiles() method and compare the file name.
XPath is a language for addressing parts of an XML document, for those who are not familiar with this language - here are the W3C specifications and here is the W3schools tutorial. Now that we know XPath, lets get to the point of that post which is - Visual XPath.
This is a free graphical XPath [...]
This one is for all you guys who are just starting to use LINQ and have no idea how to make those queries work.
I have tried it and i am glad to say that it is very friendly and usable especially if you have no experience with Linq
Linqpad is a very user friendly LINQ editor [...]
We pay for user submitted tutorials and articles that we publish. Anyone can send in a contribution
Learn More