Last active
August 29, 2015 13:57
-
-
Save baba-s/9926910 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Collections.Generic; | |
| /// <summary> | |
| /// List型の拡張メソッドを監理するクラス | |
| /// </summary> | |
| public static partial class ListExtensions | |
| { | |
| /// <summary> | |
| /// 指定したコレクションの要素を List の末尾に追加します | |
| /// </summary> | |
| /// <typeparam name="T">List の型</typeparam> | |
| /// <param name="list">List のインスタンス</param> | |
| /// <param name="collection">List の末尾に要素が追加されるコレクション</param> | |
| public static void AddRange<T>(this List<T> list, params T[] collection) | |
| { | |
| list.AddRange(collection); | |
| } | |
| /// <summary> | |
| /// List からすべての要素を削除して、指定したコレクションの要素を List に追加します | |
| /// </summary> | |
| /// <typeparam name="T">List の型</typeparam> | |
| /// <param name="list">List のインスタンス</param> | |
| /// <param name="collection">List に要素が追加されるコレクション</param> | |
| public static void Init<T>(this List<T> list, IEnumerable<T> collection) | |
| { | |
| list.Clear(); | |
| list.AddRange(collection); | |
| } | |
| /// <summary> | |
| /// List からすべての要素を削除して、指定したコレクションの要素を List に追加します | |
| /// </summary> | |
| /// <typeparam name="T">List の型</typeparam> | |
| /// <param name="list">List のインスタンス</param> | |
| /// <param name="collection">List に要素が追加されるコレクション</param> | |
| public static void Init<T>(this List<T> list, params T[] collection) | |
| { | |
| list.Clear(); | |
| list.AddRange(collection); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment