是否有 kotlin inline class 的等价物在 C# 中?
最佳答案
正如 Hans Passant 评论的那样,C#
中的结构在结果方面是等效的。
C# Struct
是一个值类型:https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/struct
A structure type (or struct type) is a value type that can encapsulate data and related functionality.
作为一个值类型,它通常被添加到堆栈中(除非它被装箱),作为 kotlin 等价物。
它也有局限性(不能扩展其他结构或类,但可以实现接口(interface),构造函数必须初始化所有内容等),但它比内联类的 alpha
版本更通用。
关于Kotlin 内联类的 C# 等价物,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63837148/