this post was submitted on 21 Jun 2023
12 points (100.0% liked)

C Sharp

1528 readers
1 users here now

A community about the C# programming language

Getting started

Useful resources

IDEs and code editors

Tools

Rules

Related communities

founded 1 year ago
MODERATORS
 

New features for those who haven't seen them:

// Primary constructors
public class NamedItem(string name)
{
    public string Name => name;
}

// Default lambda params
var IncrementBy = 
    (int source, int increment = 1) => 
        source + increment;

Console.WriteLine(IncrementBy(5)); // 6
Console.WriteLine(IncrementBy(5, 2)); // 7

// Type aliases
using Point = (int x, int y);
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 2 points 1 year ago (2 children)

Primary constructors I think are getting a bit too much bloat for the language. I get the purpose and I use them in Scala, but it just feels like too many ways to do a simple thing in C#.

Tuple type aliases FTW

Just still desperately hoping for Union types

[–] starman 1 points 1 year ago* (last edited 1 year ago) (1 children)

I heard that unions won't be implemented in C# 12, unfortunately

[–] [email protected] 2 points 1 year ago

I heard the same. The number of places I want to use something like an Option<T> instead of having to consider null values… One day though