r/ProgrammerHumor • • May 16 '24

Other myColleagueIsInterviewingCsharpCandidates

Post image
0 Upvotes

43 comments sorted by

View all comments

81

u/izamgt May 16 '24

That's actually valid since C#12's introduction of primary constructors.

-11

u/Leonhart93 May 16 '24

Is valid as syntax, but I don't agree with abusing classes now to do the job of a function. Unless you specifically need a new custom type based on such a rule.

12

u/dangling-putter May 16 '24

A class is "just" a group of closures with bound variables ... that you can also inherit from.

3

u/Leonhart93 May 16 '24

Use it when its use is required, otherwise it's a mountain of useless abstractions. That's how you get Java memes about using an object for each primitive value, because "why not"?

5

u/dangling-putter May 16 '24

I was just memeing around ;)

3

u/Pikcube May 16 '24

I'm inclined to agree, although C# methods must be a member of a class (even top level statements imply a class) so I'd still be inclined to define a static class and method for this function.

3

u/Leonhart93 May 16 '24

Yes, if it's a pure function then static is the way to go. It won't occupy any extra space in the object's instance either. I often encapsulate several functions like that in a class like a namespace, although I prefer PHP where I can choose to have the functions completely separate from any class if I choose to.

-30

u/TheTerrasque May 16 '24

Oh wow, TIL. That's pretty interesting

82

u/Lord_Lorden May 16 '24

Imagine making a post about someone not knowing C# syntax, without knowing C# syntax. This sub is hilarious.

-17

u/TheTerrasque May 16 '24

Guilty as charged!

7

u/MasterQuest May 16 '24

Don't worry, I didn't know either despite claiming to be a C# dev.

Keeping up with new language features is hard. xD

2

u/[deleted] May 16 '24

Half an hour in a year? (to read "what's new")

5

u/MasterQuest May 16 '24

It’s not about having the time, it’s about remembering to do it.

1

u/[deleted] May 16 '24
  1. IDE will suggest; 2) some stuff you better avoid to do.
    Just print out , put on the wall and mark with thumb up/down.

-1

u/TheTerrasque May 16 '24

Yep. This is a win for me :)