これらの問題を抱えていて、「クリーン」な気分になりたいときは、通常、Project Monoの善良な人々が何をしたかを見ています。
(私は自分のローカル コピーを持っているので、直接検索できますArray.cs
)... 見てみましょう。
//
// System.Array.cs
//
// Authors:
// Joe Shaw (joe@ximian.com)
// Martin Baulig (martin@gnome.org)
// Dietmar Maurer (dietmar@ximian.com)
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
// Jeffrey Stedfast (fejj@novell.com)
// Marek Safar (marek.safar@gmail.com)
//
// (C) 2001-2003 Ximian, Inc. http://www.ximian.com
// Copyright (C) 2004-2011 Novell, Inc (http://www.novell.com)
// Copyright (C) 2011 Xamarin Inc (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
public static TOutput[] ConvertAll<TInput, TOutput> (TInput [] array, Converter<TInput, TOutput> converter)
{
if (array == null)
throw new ArgumentNullException ("array");
if (converter == null)
throw new ArgumentNullException ("converter");
TOutput [] output = new TOutput [array.Length];
for (int i = 0; i < array.Length; i ++)
output [i] = converter (array [i]);
return output;
}
Reflector/ilspy を使用して .NET を参照することの合法性はグレー ゾーンですが、コードをそのままコピーすることは間違いなく間違っています。
(ファイルの著作権を追加したことに注意してください。それだけではコードよりもはるかに大きくなります:-)、技術的には、その小さなコードを使用したい場合は、そのライセンス、つまりMITライセンスを尊重する必要があるためです)