public static ExtensionMethod(this List<int> list, int percentline)
{
try
{
if (list.Count <= 100 && list.Count >= 1)
{
IEnumerable<int> count = list.OrderByDescending(sort => sort).Take((int)(list.Count() * percentline / 100.0f));
Console.WriteLine("Перечень элементов: \n" + string.Join(", ", count));
}
else
{
throw new ArgumentException();
}
}
catch (ArgumentException)
{
Console.Write("ОШИБКА!!!\n");
}
return ?????
}
public static IEnumerable<int> ExtensionMethod(this IEnumerable<int> list, int percentline)
{
try
{
if (list.Count() <= 100 && list.Count() >= 1)
{
IEnumerable<int> count = list.OrderByDescending(sort => sort).Take((int)(list.Count() * percentline / 100.0f));
Console.WriteLine("Перечень элементов: \n" + string.Join(", ", count));
}
else
{
throw new ArgumentException();
}
}
catch (ArgumentException)
{
Console.Write("ОШИБКА!!!\n");
}
return list;
}
var list = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
list
.ExtensionMethod(10)
.ExtensionMethod(25);