How can I make a function return IEnumerable<string> instead of a string in C#

c#

Solution

public static IEnumerable<string> GetFormattedErrorMessage(this Exception e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

            var exError = e.Message;
            if (e.InnerException != null)
            {
                exError += "<br>" + e.InnerException.Message;
                if (e.InnerException.InnerException != null)
                {
                    exError += "<br>" + e.InnerException.InnerException.Message;
                }
            }

            yield return exError;
        }

Problem

I have the following function that returns a string: ``` public static string GetFormattedErrorMessage(this Exception e) { if (e == null) { throw new ArgumentNullException("e"); } var exError = e.Message; if (e.InnerException != null) { exError += "<br>" + e.InnerException.Message; if (e.InnerException.InnerException != null) { exError += "<br>" + e.InnerException.InnerException.Message; } } return exError; } ``` Can someone help and tell me how I could make this same function return a `IEnumerable<string>` with just one element?

Original source