record-classes Questions
3
Using C# 9.0 records to build smart-enum-like/discriminated-union-like/sum-type-like data structure?
Playing around with the record type in C#, it looks like it could be quite useful to build discriminated-union-like data structures, and I'm just wondering if I'm missing some gotchas that I'll reg...
Diaphoresis asked 3/9, 2020 at 13:6
4
Solved
In C# 9 we can create positional records causing them to get a constructor, which the spec draft calls a primary constructor. We can create a custom constructor as well, but as stated in the spec:
...
Clathrate asked 13/12, 2020 at 1:48
2
Solved
When defining a record class, how do I target the attributes to the parameter, field or property?
For instance, I would like to use JsonIgnore but this doesn't compile as it has an attribute usage ...
Kynewulf asked 7/9, 2020 at 13:10
2
Solved
consider:
// the ratioale for Wrapper is that it has a Json serializer that
// serialize through Field (not included in this example)
record Wrapper<T> where T : notnull {
protected Wrapper...
Sensibility asked 27/9, 2020 at 23:59
6
Solved
Two questions regarding the new records feature :
How do I recognize a record using reflection ? looking [here][1] maybe there
is a way to detect the EqualityContract but I am not sure if that is ...
Jaclin asked 26/7, 2020 at 7:23
1
© 2022 - 2025 — McMap. All rights reserved.