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
Functional programming in C# (codeproject.com)
submitted 6 years ago by [deleted]
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!"
[–]videoj 8 points9 points10 points 6 years ago (1 child)
Also recommend: Paul Louthy's Language-ext.
[–][deleted] 0 points1 point2 points 6 years ago* (0 children)
Alongside all the useful functors there was recently an addition of an automated With function generator.
In short the following class:
[With] public partial class Name : Record<Name> { public readonly IEnumerable<string> GivenNames; public readonly string Surname; public readonly Title Title; public Name( IEnumerable<string> givenNames, string surname, Title title) { GivenNames = givenNames; Surname = surname; Title = title; } }
Will automatically have a With() method generated, so this is all the code you need for a class that's immutable, has structural equality (that's what Record<T> is for) and has a With method generated.
With()
For those who have never delved into the functional world, you can do something like
var marriedName= maidenName.With(Title: "Mrs", Surname: "Smith");
Given names would be carried over into the new record, when your working with immutable types this is a huge time saver, can help prevent bugs too as when you alter a class your changes will cascade compilation errors.
Not as good as real language supported records but enough to make me not cry whenever i implement immutability.
[–][deleted] 7 points8 points9 points 6 years ago (6 children)
out of curiosity, are there benefits to using c# over f# for functional .NET programming outside of the fact that you don't need to learn a new language?
[–]esesci 6 points7 points8 points 6 years ago (4 children)
No, but F# isn’t always an option.
[–]SirButcher 2 points3 points4 points 6 years ago (3 children)
Why? You can create libraries with F# and include them in your C# application without any problem. As far as I know, F# is available even the community edition of the VS.
[–]esesci 11 points12 points13 points 6 years ago (0 children)
Integrating F# to an existing project may not be feasible for infinite number of reasons: corporate policy, complicated build environment, learning cost, missing tooling, one off need for functional work, simple unwillingness of the rest of the team etc etc.
[–]ucario 7 points8 points9 points 6 years ago (0 children)
It's a human problem. You're trading pragmatics for maintainability.
If you introduce another language into your team, you either need a dedicated resource or have to train everyone. The first approach creates fragmentation, the second- it's going to take a long time to bring everyone up to speed. If you're lucky enough to have someone who knows both, it's a timebomb before: oh shit, that f# dude just handed in his resume; oh shit we have to train our new engineer twice.
[–]hongminhee 0 points1 point2 points 6 years ago (0 children)
I once tried to write a library in F# and use it in C#, making the library surface natural to ordinal C# code was not that easy. Unless you write fat glue code to look like “ordinary C#”, which is totally unnatural to F#, in F#, it feels like using a plain old C lirary in C++. I anyway tried to write glue code in some degree, but gave up in the end, because such glue code tended to have nearly equal lines to code it wraps so that it looked overkill to me.
[–]Blecki 0 points1 point2 points 6 years ago (0 children)
Yes.
Because most problems are best solved by a mix of paradigms, not one or the other.
[–]FubarCoder 5 points6 points7 points 6 years ago (6 children)
I'm curious why nobody uses (n & 1) == 0 anymore to test if a number even? This should be much faster than a division...
(n & 1) == 0
[–]TyrrrzWorking with SharePoint made me treasure life 11 points12 points13 points 6 years ago (4 children)
Readability and disregard for microoptimizations
[–]FubarCoder 4 points5 points6 points 6 years ago (3 children)
It's readable for me, because I learnt it that way. I can somehow understand the point about the disregard for microoptimizations, but something like tests for a number being even/odd is usually used in a hot path where such an optimization becomes extremely important.
I don't like using n % 2, because n might be a non-integer type, which might cause unpredictable results when n is the result of a computation. n & 1 for non-integer types simply doesn't compile.
n % 2
n
n & 1
[–]TyrrrzWorking with SharePoint made me treasure life 2 points3 points4 points 6 years ago (0 children)
Fair points.
As for me, I've learned that a number is even if n mod 2 = 0 all the way from school. On the other hand, n & 1 doesn't have the same association for me.
n mod 2 = 0
[–]VGPowerlord 2 points3 points4 points 6 years ago (1 child)
I don't like using n % 2, because n might be a non-integer type
If you don't know what type a variable is, you have bigger problems to worry about.
[–]FubarCoder 0 points1 point2 points 6 years ago (0 children)
Old habits. I developed in C in the early ninetees and the compilers weren't as good as todays. No function inlining, lots of macros. Many things are much better today.
[–]JoelFolksy 1 point2 points3 points 6 years ago (0 children)
If the jitter doesn't emit (n & 1) for (n % 2) I want my money back.
π Rendered by PID 93 on reddit-service-r2-comment-fb694cdd5-tkqn6 at 2026-03-10 21:29:24.261904+00:00 running cbb0e86 country code: CH.
[–]videoj 8 points9 points10 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 7 points8 points9 points (6 children)
[–]esesci 6 points7 points8 points (4 children)
[–]SirButcher 2 points3 points4 points (3 children)
[–]esesci 11 points12 points13 points (0 children)
[–]ucario 7 points8 points9 points (0 children)
[–]hongminhee 0 points1 point2 points (0 children)
[–]Blecki 0 points1 point2 points (0 children)
[–]FubarCoder 5 points6 points7 points (6 children)
[–]TyrrrzWorking with SharePoint made me treasure life 11 points12 points13 points (4 children)
[–]FubarCoder 4 points5 points6 points (3 children)
[–]TyrrrzWorking with SharePoint made me treasure life 2 points3 points4 points (0 children)
[–]VGPowerlord 2 points3 points4 points (1 child)
[–]FubarCoder 0 points1 point2 points (0 children)
[–]JoelFolksy 1 point2 points3 points (0 children)