c# 7.x using a short name for tuple type

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


c# 7.x using a short name for tuple type



Anyways to use shortcuts for Tuple types, but still preserve the names for each item in the Tuple? (I have created the examples in the code below with my comments.)


/* This way is desired because it keeps the naming for each item in the Tuple,
but incorrect for C# 7.x */
using Employee = (string Name, DateTime StartTime, DateTime LeaveTime,
int Id, double Payment);

/* This way is correct in C# 7.x grammar, but I lost all the names for the items,
and I have to using Item1, Item2 and so on.... */
using Employee = Tuple<string, DateTime, DateTime, int, double>;

public class TestFunc
{
public Employee GetEmployee()
{
Employee value;
value.Name = "Steve";
value.StartTime = new DateTime();
value.EndTime = new DateTime();
return value;
}
}





Is the first one valid C# at all?
– john
6 secs ago









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Makefile test if variable is not empty

Will Oldham

'Series' object is not callable Error / Statsmodels illegal variable name