Cannot implicitly convert type ...
Posted
by Newbie
on Stack Overflow
See other posts from Stack Overflow
or by Newbie
Published on 2010-05-27T10:51:28Z
Indexed on
2010/05/27
11:01 UTC
Read the original article
Hit count: 188
c#3.0
I have the following function
public Dictionary<DateTime, object> GetAttributeList(
EnumFactorType attributeType
,Thomson.Financial.Vestek.Util.DateRange dateRange)
{
DateTime startDate = dateRange.StartDate;
DateTime endDate = dateRange.EndDate;
return ((
//Step 1: Iterate over the attribute list and filter the records by
// the supplied attribute type
from assetAttribute in AttributeCollection
where assetAttribute.AttributeType.Equals(attributeType)
//Step2:Assign the TimeSeriesData collection into a temporary variable
let timeSeriesList = assetAttribute.TimeSeriesData
//Step 3: Iterate over the TimeSeriesData list and filter the records by
// the supplied date
from timeSeries in timeSeriesList.ToList()
where timeSeries.Key >= startDate && timeSeries.Key <= endDate
//Finally build the needed collection
select new AssetAttribute()
{
TimeSeriesData = PopulateTimeSeriesData(timeSeries.Key, timeSeries.Value)
}).ToList<AssetAttribute>().Select(i => i.TimeSeriesData));
}
private Dictionary<DateTime, object> PopulateTimeSeriesData(DateTime dateTime, object value)
{
Dictionary<DateTime, object> timeSeriesData = new Dictionary<DateTime, object>();
timeSeriesData.Add(dateTime, value);
return timeSeriesData;
}
Error:Cannot implicitly convert type 'System.Collections.Generic.IEnumerable>' to 'System.Collections.Generic.Dictionary'. An explicit conversion exists (are you missing a cast?)
Using C#3.0
Please help
© Stack Overflow or respective owner