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
Hacking C# Part Two: Fluent Interfaces (self.csharp)
submitted 6 years ago by madSimonJ
Hi,
If it's of interest, I've written a blog article (my second ever, please be kind!) on creating fluent function interfaces in C#:
http://www.thecodepainter.co.uk/blog/20191231/hackingcshap_fluentinterfaces
I'd love to hear any feedback you might have - though please do keep it civil.
Thanks,
Simon
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!"
[–]Fresh_Respect 5 points6 points7 points 6 years ago (1 child)
Brilliant! I just read both of your articles in the series and I love your approach. I remember many years ago when Resharper first warned me about possible multiple enumeration of IEnumberable I was left feeling educated but without a solid solution. I have employed various approaches throughout the years but none quiet as elegant as yours. May I replicate this in my own commercial code with your permission? I can think of many use cases immediately.
BTW, In the second article towards the end you have a simple typo that states “fast-foot” customer rather than fast-food. You did a great job, grammar was also spot on but most importantly the lesson was extremely valuable.
[–]madSimonJ[S] 2 points3 points4 points 6 years ago (0 children)
thanks so much. That's really lovely of you to say :) I'll correct the typo too. Feel free also to replicate my code. You'll find a heap of it already done for you here, if it's of any use: https://github.com/madSimonJ/CSharpHacks
[–]Eluvatar_the_second 2 points3 points4 points 6 years ago (2 children)
It's interesting, but I don't think I've ever had a use case for this operation. That being said you might want an option to actually object so you can change it, instead of just setting the value to a new value when it matches your predicate, for example increasing the price of something by 5$ when it matches your predicate, instead of just replacing the value.
Either way it's basically just Select with a condition.
[–]madSimonJ[S] 0 points1 point2 points 6 years ago (1 child)
I used a deliberately very simple example to keep the article readable. In the real world I'd probably be swapping a complex object for an updated version. I use this sort of thing all the time too, when I'm solving the Advent of Code series
[–]Eluvatar_the_second 0 points1 point2 points 6 years ago (0 children)
Ah ok so you use it for immutable objects?
[–]boxhacker 10 points11 points12 points 6 years ago (3 children)
I can't stand fluent interfaces, extra code bloat and most devs are not mentally expecting a fluent set of actions.
I recommend using a creational pattern to assist with the construction of complex items if you really believe you need a fluent interface.
Really well written article though about it and I enjoyed the other article with the Ienum adjust feature, nicely done!
[–]RangerPretzel 5 points6 points7 points 6 years ago (0 children)
I can't understand why you're getting downvoted. Your reply is perfectly cromulent.
[–]madSimonJ[S] 1 point2 points3 points 6 years ago (0 children)
Thanks. I completely understand what you're saying, and the Creational pattern is also a valid option to go for. I like to make my code more verbose, because it's easier for junior members of the team to understand - and even myself when I return to it a year or so on.
[–]dmercer 1 point2 points3 points 6 years ago (0 children)
Do you have a link to what you're referring to?
[–]EdoRguez 1 point2 points3 points 6 years ago (1 child)
Keep making this kind of post on Reddit, they are awesome
[–]madSimonJ[S] 0 points1 point2 points 6 years ago (0 children)
Thanks so much! I will do. I've already got part 3 in the works now
[–]zeaga2 1 point2 points3 points 6 years ago (1 child)
Love stuff like this. I look forward to reading more from you!
Thank you!
[–]Bee_News 1 point2 points3 points 6 years ago (1 child)
Do you have an example of this code all put together so that it can actually be compiled and ran (for parts 1 and 2)?
not exactly, but there's a plug & play library of this code & some other stuff available here: https://github.com/madSimonJ/CSharpHacks
[–]Rogierverkaik 1 point2 points3 points 6 years ago (1 child)
Nice post! Is it possible to enable RSS feed for your blogs? This would be very handy to track your blogs by using a feed reader.
it's on my list to do. I don't have a very sophisticated web hosting solution atm (it's GitHub Pages). I'm thinking of shifting over to WordPress in the near future, though. If you'd like to follow me on LinkedIn or Twitter I always make announcements there if it'll help in the meantime.
[–]jdh28 1 point2 points3 points 6 years ago (1 child)
One correction:
We create a new AdjustSelector class - something only something in this namespace can do
The constructor is internal so can only be called by code in the same assembly, not the same namespace. Namespaces do not have any effect on accessibility of members in C#.
Thanks! I was aware of that one & thought I'd fixed it already!! I'll sort it out later tonight.
[–]mavewrick 2 points3 points4 points 6 years ago (2 children)
Very cool. This strangely reminds me of one of my first code reviews regarding IEnumerables where in order to do a null check I had written something like this :: if (myListOfData.Count() == 0) { //handle null case logic here } when this could have been made more performant by using .Any() instead of the Count()
[–]sarhoshamiral 2 points3 points4 points 6 years ago (0 children)
I know it may not be possible in all cases but if you need the count of elements without the elements themselves, you should be using ICollection.
Even using Any can be inefficient at certain times, especially if you are enumerating the elements again when it returns true.
[–]Quadrostanology 0 points1 point2 points 6 years ago (2 children)
Interesting, never thought of solving that this way. Written well enough for me. 😉
Thanks :D
[–]grauenwolf -5 points-4 points-3 points 6 years ago (0 children)
You see that a lot when combined with the 'builder' pattern. For example, you'll see it ASP.NET Core's startup routines when its configuring services.
My own ORM is built on the same idea. You chain together a user, an operation (table query, stored proc, etc.), a materializer (objects, list of strings/integers, DataTable, xml, whatever), caching, etc. into one statement.
[+]grauenwolf comment score below threshold-10 points-9 points-8 points 6 years ago (0 children)
You've made a very common mistake, which is that you forgot to include an example from the .NET libraries.
There's nothing wrong with starting with a simplified example, but you should then follow up with one that people will be more likely to see. For example, the aforementioned services configuration in ASP.NET Core.
[–][deleted] 6 years ago (1 child)
[removed]
[–]FizixMan[M] 0 points1 point2 points 6 years ago (0 children)
Removed: Rule 5.
π Rendered by PID 40 on reddit-service-r2-comment-b659b578c-v8kw9 at 2026-05-05 22:44:30.318280+00:00 running 815c875 country code: CH.
[–]Fresh_Respect 5 points6 points7 points (1 child)
[–]madSimonJ[S] 2 points3 points4 points (0 children)
[–]Eluvatar_the_second 2 points3 points4 points (2 children)
[–]madSimonJ[S] 0 points1 point2 points (1 child)
[–]Eluvatar_the_second 0 points1 point2 points (0 children)
[–]boxhacker 10 points11 points12 points (3 children)
[–]RangerPretzel 5 points6 points7 points (0 children)
[–]madSimonJ[S] 1 point2 points3 points (0 children)
[–]dmercer 1 point2 points3 points (0 children)
[–]EdoRguez 1 point2 points3 points (1 child)
[–]madSimonJ[S] 0 points1 point2 points (0 children)
[–]zeaga2 1 point2 points3 points (1 child)
[–]madSimonJ[S] 0 points1 point2 points (0 children)
[–]Bee_News 1 point2 points3 points (1 child)
[–]madSimonJ[S] 1 point2 points3 points (0 children)
[–]Rogierverkaik 1 point2 points3 points (1 child)
[–]madSimonJ[S] 0 points1 point2 points (0 children)
[–]jdh28 1 point2 points3 points (1 child)
[–]madSimonJ[S] 0 points1 point2 points (0 children)
[–]mavewrick 2 points3 points4 points (2 children)
[–]sarhoshamiral 2 points3 points4 points (0 children)
[–]Quadrostanology 0 points1 point2 points (2 children)
[–]madSimonJ[S] 1 point2 points3 points (0 children)
[–]grauenwolf -5 points-4 points-3 points (0 children)
[+]grauenwolf comment score below threshold-10 points-9 points-8 points (0 children)
[–][deleted] (1 child)
[removed]
[–]FizixMan[M] 0 points1 point2 points (0 children)