Hex Dump using LINQ (in 7 lines of code)

Posted by: Fabrice's weblog, on 12 Mar 2010 | View original | Bookmarked: 0 time(s)

Eric White has posted an interesting LINQ query on his blog that shows how to create a Hex Dump in something like 7 lines of code.Of course, this is not production grade code, but it's another good example that demonstrates the expressiveness of LINQ.Here is the code:byte[] ba = File.ReadAllBytes("test.xml");int bytesPerLine = 16;string hexDump = ba.Select((c, i) => new { Char = c, Chunk = i / bytesPerLine })    .GroupBy(c => c.Chunk)    .Select(g => g.Select(c...

Advertisement
Free Agile Project Management Tool from Telerik
TeamPulse Community Edition helps your team effectively capture requirements, manage project plans, assign and track work, and most importantly, be continually connected with each other.
Category: XLinq | Other Posts: View all posts by this blogger | Report as irrelevant | View bloggers stats | Views: 732 | Hits: 18

Similar Posts

  • LINQ in Action samples in LINQPad more
  • Creating LINQToTwitter library using LinqExtender more
  • Back to CSV - Convert CSV text to Objects; via JSON more
  • Athena - A LINQ to flickr API (Release 1.4) more
  • Implementing SqlBulkCopy in Linq to Sql more
  • DevConnections Spring Slides and Demos more
  • LINQPad as a Code Snippet Execution Engine more
  • Dynamic Queries and LINQ Expressions more
  • Is V1 of LINQ to SQL only suitable for RAD? more
  • Screencast: Enable Server Mode using LINQ (ASPxGridView & XtraGrid) more

News Categories

.NET | Agile | Ajax | Architecture | ASP.NET | BizTalk | C# | Certification | Data | DataGrid | DataSet | Debugger | DotNetNuke | Events | GridView | IIS | Indigo | JavaScript | Mobile | Mono | Patterns and Practices | Performance | Podcast | Refactor | Regex | Security | Sharepoint | Silverlight | Smart Client Applications | Software | SQL | VB.NET | Visual Studio | W3 | WCF | WinFx | WPF | WSE | XAML | XLinq | XML | XSD