Align ToString implementations for immutable collections to record types ToString #4346
-
In C# 9 record types got introduced which are absolutely awesome. These bring a lot of goodness from immutable data structures as we have them in F# to C# now. Even better, record types have a nice implementation of public record Foo
{
public string MyString {get; init;}
public Bar MyBar {get; init;}
public IImmutableList<int> MyList {get; init;}
}
public record Bar
{
public float MyFloat {get; init;}
}
Foo foo = new Foo()
{
MyString = "Hello World",
MyBar = new Bar() {MyFloat = 47.11},
MyList = ImmutableList.Create<int>(3, 5, 7)
};
Console.WriteLine(foo.ToString()); prints
instead of
which most developers would desire when using value types and immutable data structures. Would it be possible to change the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
This would be a question for dotnet/runtime. |
Beta Was this translation helpful? Give feedback.
This would be a question for dotnet/runtime.