これが私のいくつかです:
// returns the number of milliseconds since Jan 1, 1970 (useful for converting C# dates to JS dates)
public static double UnixTicks(this DateTime dt)
{
DateTime d1 = new DateTime(1970, 1, 1);
DateTime d2 = dt.ToUniversalTime();
TimeSpan ts = new TimeSpan(d2.Ticks - d1.Ticks);
return ts.TotalMilliseconds;
}
および ToDelimitedString 関数:
// apply this extension to any generic IEnumerable object.
public static string ToDelimitedString<T>(this IEnumerable<T> source, string delimiter, Func<T, string> action)
{
if (source == null)
{
throw new ArgumentException("Source can not be null.");
}
if (delimiter == null)
{
throw new ArgumentException("Delimiter can not be null.");
}
string strAction = string.Empty;
string delim = string.Empty;
var sb = new StringBuilder();
foreach (var item in source)
{
strAction = action.Invoke(item);
sb.Append(delim);
sb.Append(strAction);
delim = delimiter;
}
return sb.ToString();
}