Hi,
I have to parse a date string. the year, month and day can all be in various formats (year in "yy" or "yyyy").
To get an array of valid formats, I have each date-part in a separate array. I join all of these together using the Join(this Enumerable source) linq extension. Code below:
private string[] years = { "yy", "yyy" };
private string[] months = { "M", "MM" };
private string[] days = { "d", "dd" };
string[] formats
{
get
{
return years.Join(
months,
y => 1,
m => 1,
(y, m) => new {y, m}
).Join(
days,
n => 1,
d => 1,
(n, d) => string.Join("/", n.y, n.m, d)
).ToArray();
}
}
I'm sure you can see the bit I don't like. Joining tables on 1=1, bleh!
I prefer extension syntax to linq syntax, so I won't be using that, but it's popularity makes google searches all the more difficult.
So: How SHOULD I be joining these arrays?
Thanks ^_^
Andy