5 ms·
well to do anything new in a C# project one typically ends up making a class inside a new namespace, if I just want to write a solver with no state it's quite j
by mhh__ 1y ago
well to do anything new in a C# project one typically ends up making a class inside a new namespace, if I just want to write a solver with no state it's quite jarring and distracts from otherwise a pretty good language that I like working in. So 2 new nouns and a handful of keywords.
- motorest 1y ago> well to do anything new in a C# project one typically ends up making a class inside a new namespace (...) You don't need to. A few years ago, C# introduced top-level statements. They were introduced in 2020, I think. https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/program-structure/top-level-statements https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals...
- voidUpdate 1y agoA namespace isn't required
- metaltyphoon 1y agoIt’s clear you haven’t run `dotnet new console` in years or you wouldn’t be saying this.
- GoblinSlayer 1y agoYou want to write something in C# smaller than 10 words?
- int_19h 1y agoHello world in C# today looks like this: System.Console.WriteLine("Hello world!"); That's it. No namespaces (which were never required anyway, not even in C# 1.0), no classes, no functions even. If you want to define a function, you can just do so in global scope, and if it's a single expression you don't even need the braces: int Fib(int n) => (n <= 1) ? n : Fib(n - 1) + Fib(n - 2);