You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
C# currently supports tuples with specifically-named properties, like defining:
(double x,double y)point=(1,2);// to access - point.x, point.y
Which is great, by the way. It allows creating simple struct-ish types that you can use, for example, for return types or type arguments.
However, a repetitiveness problem may arise: if your function, say, returns an IReadOnlyCollection<(int id, string result)> (sorry for lack of creativity), and you'll want another function to accept that as a parameter, you need to again write IReadOnlyCollection<(int id, string result)>, which gets more frustrating when names get just a bit longer.
What I'm suggesting is that you'd be able to declare a named-tuple like a named type:
publictypePoint=(int x,int y);
I've seen a suggestion to do that similar to a using directive, similar to how you can already write something like:
using ShortTypeName =SomeGenericType<TArg1,TArg2>;
But what I'm suggesting is something that will have an access modifier and can be part of a namespace or nested in another type, similar to a delegate declaration. That way you can use it outside of the same CS file, unlike an alias of a using directive.
The text was updated successfully, but these errors were encountered:
C# currently supports tuples with specifically-named properties, like defining:
Which is great, by the way. It allows creating simple struct-ish types that you can use, for example, for return types or type arguments.
However, a repetitiveness problem may arise: if your function, say, returns an
IReadOnlyCollection<(int id, string result)>
(sorry for lack of creativity), and you'll want another function to accept that as a parameter, you need to again writeIReadOnlyCollection<(int id, string result)>
, which gets more frustrating when names get just a bit longer.What I'm suggesting is that you'd be able to declare a named-tuple like a named type:
I've seen a suggestion to do that similar to a
using
directive, similar to how you can already write something like:But what I'm suggesting is something that will have an access modifier and can be part of a namespace or nested in another type, similar to a delegate declaration. That way you can use it outside of the same CS file, unlike an alias of a using directive.
The text was updated successfully, but these errors were encountered: