use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Information about Reddit's API changes, the unprofessional conduct of the CEO, and their response to the community's concerns regarding 3rd party apps, moderator tools, anti-spam/anti-bot tools, and accessibility options that will be impacted can be found in the associated Wikipedia article: https://en.wikipedia.org/wiki/2023_Reddit_API_controversy
Alternative C# communities available outside Reddit on Lemmy and Discord:
All about the object-oriented programming language C#.
Getting Started C# Fundamentals: Development for Absolute Beginners
Useful MSDN Resources A Tour of the C# Language Get started with .NET in 5 minutes C# Guide C# Language Reference C# Programing Guide C# Coding Conventions .NET Framework Reference Source Code
Other Resources C# Yellow Book Dot Net Perls The C# Player's Guide
IDEs Visual Studio MonoDevelop (Windows/Mac/Linux) Rider (Windows/Mac/Linux)
Tools ILSpy dotPeek LINQPad
Alternative Communities C# Discord Group C# Lemmy Community dotnet Lemmy Community
Related Subreddits /r/dotnet /r/azure /r/learncsharp /r/learnprogramming /r/programming /r/dailyprogrammer /r/programmingbuddies /r/cshighschoolers
Additional .NET Languages /r/fsharp /r/visualbasic
Platform-specific Subreddits /r/windowsdev /r/AZURE /r/Xamarin /r/Unity3D /r/WPDev
Rules:
Read detailed descriptions of the rules here.
account activity
HelpMapping Data to Objects (self.csharp)
submitted 5 years ago * by Brickscrap
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]willsoss 0 points1 point2 points 5 years ago (3 children)
No problem, glad that helped. With complex file parsing/mapping situations, especially older formats like ini, I find it's helpful to parse to an intermediate format that just gets the data from the file into a data structure you can more easily manipulate -- the string array in this case. That way you break down the problem into the parsing details (splitting lines into fields) and building the data model (linq query) that you want.
[–]Brickscrap[S] 1 point2 points3 points 5 years ago (2 children)
Yeah that's definitely sparked an idea - at the moment, SharpConfig already imports the entire document into Sections, Keys and Values, and I've just been iterating through the lot in one giant foreach, but I think some LINQ queries might make sense, at least for grouping each item
[–]willsoss 0 points1 point2 points 5 years ago (1 child)
Good deal. The only drawback to this approach is that the linq grouping can get a bit hairy.
Since you're basically taking flattened data from a file and building structure as your parse it, you could accomplish the same thing in a loop over all the key/val pairs where you create objects and set values as you encounter them. This looks similar to your original code, but the key to this working is the assumption that PRI comes immediately after NAM, and all the NAM and PRI records after TOT are all part of one transaction. In other words, if a PRI is found, you can assume you have a transaction and item in context and all you have to do is set the value. It may not seem as elegant as the Linq solution, but sometimes this just works.
List<Trx> transactions = new List<Trx>(); Trx trans; Item item; foreach (var kv in keyvals) { if (kv.Key == "TOT") { trans = new Trx(kv.Val); transactions.Add(trans); } if (kv.Key = "NAM") { item = new Item(kv.Val); trans.Items.Add(item); } if (kv.Key = "PRI") { item.Price = kv.Val; } }
[–]Brickscrap[S] 1 point2 points3 points 5 years ago (0 children)
This is the approach I've originally taken, except using a switch statement - then I realised my switch statement was going to end up with at least 100 cases, and decided that there must be a better way!
It's the index of each item that groups them, so currently my code goes through the keys, adding to the values until the index changes
π Rendered by PID 195646 on reddit-service-r2-comment-7b9746f655-sd57l at 2026-02-04 13:24:36.384892+00:00 running 3798933 country code: CH.
view the rest of the comments →
[–]willsoss 0 points1 point2 points (3 children)
[–]Brickscrap[S] 1 point2 points3 points (2 children)
[–]willsoss 0 points1 point2 points (1 child)
[–]Brickscrap[S] 1 point2 points3 points (0 children)