1 // ================================================================================================
3 // コレクション/配列処理に関するユーティリティクラスソース。</summary>
5 // <copyright file="CollectionUtils.cs" company="honeplusのメモ帳">
6 // Copyright (C) 2012 Honeplus. All rights reserved.</copyright>
9 // ================================================================================================
11 namespace Honememo.Utilities
14 using System.Collections.Generic;
17 /// コレクション/配列処理に関するユーティリティクラスです。
19 public static class CollectionUtils
24 /// 指定された文字列が渡されたコレクション内に存在するかを大文字小文字を無視して判定する。
26 /// <param name="collection">探索するコレクション。</param>
27 /// <param name="item">含まれるか判定する文字列。</param>
28 /// <returns>指定された文字列が含まれる場合<c>true</c>。</returns>
29 /// <exception cref="ArgumentNullException"><para>collection</para>が<c>null</c>の場合。</exception>
30 public static bool ContainsIgnoreCase(IEnumerable<string> collection, string item)
32 foreach (string s in Validate.NotNull(collection))
34 if (s == item || (s != null && item != null && s.ToLower() == item.ToLower()))
48 /// 渡された文字列配列の中の要素を全て<see cref="String.Trim()"/>した配列を返す。
50 /// <param name="array"><c>Trim</c>する文字列配列。</param>
51 /// <returns><c>Trim</c>された文字列配列。</returns>
52 /// <exception cref="ArgumentNullException"><para>array</para>が<c>null</c>の場合。</exception>
53 /// <remarks><para>array</para>中に<c>null</c>要素が存在するのは可。</remarks>
54 public static string[] Trim(string[] array)
56 string[] result = new string[Validate.NotNull(array).Length];
57 for (int i = 0; i < array.Length; i++)