29 lines
900 B
C#
29 lines
900 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace EvoCalculator.Core.Tools.GroupColumns;
|
|
|
|
public static partial class GroupColumns
|
|
{
|
|
public static List<KeyValuePair<DateTime, decimal>> Create(IEnumerable<DateTime> dates,
|
|
IEnumerable<decimal> values)
|
|
{
|
|
return dates
|
|
.Select((x, i) => new KeyValuePair<DateTime, decimal>(x, values.ElementAtOrDefault(i)))
|
|
.ToList();
|
|
}
|
|
|
|
public static List<KeyValuePair<DateTime, decimal>> CreateMatchedLength(IEnumerable<DateTime> dates,
|
|
IEnumerable<decimal> values)
|
|
{
|
|
int minLength = Math.Min(dates.Count(), values.Count());
|
|
|
|
List<KeyValuePair<DateTime, decimal>> result = dates
|
|
.Zip(values, (date, value) => new KeyValuePair<DateTime, decimal>(date, value))
|
|
.Take(minLength)
|
|
.ToList();
|
|
|
|
return result;
|
|
}
|
|
} |