Will a future version of .NET support tuples in C#?

前端 未结 12 1725
别那么骄傲
别那么骄傲 2020-11-28 23:54

.Net 3.5 doesn\'t support tuples. Too bad, But not sure whether the future version of .net will support tuples or not?

12条回答
  •  眼角桃花
    2020-11-29 00:21

    C# supports simple tuples via generics quite easily (as per an earlier answer), and with "mumble typing" (one of many possible C# language enhancements) to improve type inference they could be very, very powerful.

    For what it is worth, F# supports tuples natively, and having played with it, I'm not sure that (anonymous) tuples add much... what you gain in brevity you lose very quickly in code clarity.

    For code within a single method, there are anonymous types; for code going outside of a method, I think I'll stick to simple named types. Of course, if a future C# makes it easier to make these immutable (while still easy to work with) I'll be happy.

提交回复
热议问题