Earlier quoted context omitted.
My understanding is that the dotnet runtime and powershell are both decent codebases. https://github.com/dotnet/runtime https://github.com/PowerShell/PowerShell
Looking at a random file in Powershell, the first thing I see is: private string _typeName; /// /// Add new type name to the specified object for TypeNameSet. /// [Parameter(Mandatory = true, ParameterSetName = "TypeNameSet")] [Parameter(ParameterSetName = "MemberSet")] [Parameter(ParameterSetName = NotePropertySingleMemberSet)] [Parameter(ParameterSetName = NotePropertyMultiMemberSet)] [ValidateNotNullOrEmpty] publi…
Welcome to C# 9.0
121–130 of 196 posts
Re: Welcome to C# 9.0
#122Damn, this is fantastic. One big syntactical thing I should really put in a proposal for is null-conditional returns. Turning if(foo != null) return foo; Into return? foo; It fits perfectly with the existing null coalescing operators and such, while really cleaning up a lot of code.
If it returns null, what's the difference between:
>return foo;
and
>return? foo;
?
Re: Welcome to C# 9.0
#123Earlier quoted context omitted.
The point of C# being a better Java is nowadays mostly obscolete because of Kotlin being THE better Java. As for LINQ see https://github.com/mythz/kotlin-linq-examples/blob/master/RE...
Why don't people understand that LINQ isn't just a C#-ish way to write SQL-like statements? So many people are comparing their libraries to LINQ without understanding what it actually does. LINQ brought System.Linq.Expressions and IQueryable to .NET which allows so much more than just filtering and grouping data. You can write entire data providers with LINQ and parse arbitrary expression trees in any way you like. E…
Expression>Re: Welcome to C# 9.0
#124Damn, this is fantastic. One big syntactical thing I should really put in a proposal for is null-conditional returns. Turning if(foo != null) return foo; Into return? foo; It fits perfectly with the existing null coalescing operators and such, while really cleaning up a lot of code.
if(?foo){return null}
Re: Welcome to C# 9.0
#125> " Top-level programs " I'm not usually one for causal dismissals but that made me cringe. What on earth is the use case for getting rid of that tiny bit of boilerplate, relative to the complexity it adds to the language definition, that makes it worthwhile?
Re: Welcome to C# 9.0
#126> " Top-level programs " I'm not usually one for causal dismissals but that made me cringe. What on earth is the use case for getting rid of that tiny bit of boilerplate, relative to the complexity it adds to the language definition, that makes it worthwhile?
In C# I'd like to able to : - declare a namespace for the file (no indentation) - declare that the file is a class and can only contain one (top level) class (still no indentation) - `using` statements that don't import every symbol into my namespace : using System.Console; ... Console.WriteLine(); instead of : using Sytem; ... Console.WriteLine(); // where does "Console" come from ? god/IDE only knows But yes, no to…
using Console = System.Console;Re: Welcome to C# 9.0
#127which visual studio version will support c# 9?
Now you can test C# 9 with Visual Studio Preview and .NET 5.0 preview https://visualstudio.microsoft.com/vs/preview/ https://dotnet.microsoft.com/download/dotnet/5.0
Re: Welcome to C# 9.0
#128Positional records are a terrible idea, one of the best things about C# is readability var (f, l) = person; is so much worse than var (f, l) = (person.FirstName, person.LastName); I don't want to have to refer to documentation or class implementation to understand what a destructuring expression does.
I disagree. Automatic destructuring like this can be fantastic. Sure, if you're just destructuring a variable there's not much gain. But this is much smoother: var (f, l) = SomeMethodReturningAPerson(); than: var person = SomeMethodReturningAPerson(); var (f, l) = (person.FirstName, person.LastName); or: foreach(var (f, l) in enumerationOfPersons) { ... } compared to: foreach(var person in enumerationOfPersons) { var…
foreach(var (f, l) in enumerationOfPersons) { ... }
tells him absolutely nothing about what's going or even that there are names involved
foreach(var (firstName, lastName) in enumerationOfPersons) { ... }
is better but doesn't give him an object to inspect to see where they come from and what else is available.
Re: Welcome to C# 9.0
#129Look - I don't have anything deep to say here. I can only say that between 'records' and 'with-expressions' now in C#, I as a hobbyist F# developer feel like I'm being shaken down by the mafia. C# designers: "Hey, nice language features you have there. I'll just borrow them for a bit ok, it'll be fine..." Later, C# programmers: "why would I learn F#, C# does all the same stuff!" (even though it doesn't) Edit: I admit…
C# takes the nice features of F# and implements in a slightly worse way.
Re: Welcome to C# 9.0
#130Damn, this is fantastic. One big syntactical thing I should really put in a proposal for is null-conditional returns. Turning if(foo != null) return foo; Into return? foo; It fits perfectly with the existing null coalescing operators and such, while really cleaning up a lot of code.
while (!return? foo) {
foo = get_foo();
}