Error CS0161 'StringUtility.SummerizeText(string, int)': not all code paths return a value

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace helloworld
{
public class StringUtility
{
public static string SummerizeText(string text, int maxLength = 50)
{

        if (text.Length < maxLength)

            Console.WriteLine(text);

        else
        {
            var words = text.Split(' ');
            var totalCharacters = 0;
            var summaryWords = new List<string>();

            foreach (var word in words)
            {
                summaryWords.Add(word);

                totalCharacters += word.Length + 1;
                if (totalCharacters > maxLength)
                    break;
            }
            var summary = String.Join(" ", summaryWords) + "!!!";
            Console.WriteLine(summary);

        }
    } 
}

}

The return type of your function is string but you don’t return one. In fact you don’t ever return anything.

Either change the return type to void or replace the Console.WriteLine calls by return statements.