Q:

Assign a function's returned IEnumerable value to another object

I am calling this function from another function:
        private static IEnumerable<MovingAverage> SimpleMovingAverage(
        IEnumerable<IexTradingStock> queue, int period)
        .
        . (omitted code) 
        .
    {   return movingAverages;

This is the function that calls MovingAverage:
                MovingAverage SMA = new MovingAverage();
            SMA = SimpleMovingAverage(stocks, period);

I get an error on this line "SMA = SimpleMovingAverage(stocks, period);"  The error is "Cannot implicitly convert type 'System.Collections.Generic.IEnumerable' to 'myBackEnd.Models.MovingAverage' an explicit conversions e xists (are you missing a cast)

A:

Your function return type should be IEnumerable not a single object. When you have declared this function you set its return type as IEnumerable but when in your return statement your are returning a single object of MovingAverage. The returned object should be same as you have declared your return type. Secondly when you are getting the list from SimpleMovingAverage(stocks, period); and setting the list in MovingAverage SMA = new MovingAverage(); is wrong. It should be.
IEnumerable<MovingAverage>  SMA = SimpleMovingAverage(stocks, period);

