using System;
using System.Collections.Generic;
public static class ListExtensions
{
public static T Pop<T>(this List<T> list)
{
if (list == null || list.Count == 0)
{
throw new InvalidOperationException("The list is empty.");
}
T value = list[0];
list.RemoveAt(0);
return value;
}
}
C# でPop処理を拡張メソッドにする
開発