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);
}
}
}
}