本文整理匯總了C#中System.Array.ThrowIfNull方法的典型用法代碼示例。如果您正苦於以下問題:C# Array.ThrowIfNull方法的具體用法?C# Array.ThrowIfNull怎麽用?C# Array.ThrowIfNull使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Array
的用法示例。
在下文中一共展示了Array.ThrowIfNull方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Copy
/// <summary>
/// Copies a range of elements from an array starting at the first element and pastes them into another array starting
/// at
/// the first element. The length is specified as a 32-bit integer.
/// </summary>
/// <exception cref="ArgumentNullException">The source array can not be null.</exception>
/// <exception cref="ArgumentNullException">The Destination array can not be null.</exception>
/// <param name="sourceArray">The array that contains the data to copy.</param>
/// <param name="destinationArray">The array that receives the data.</param>
/// <param name="length">A 32-bit integer that represents the number of elements to copy.</param>
public static void Copy( this Array sourceArray, Array destinationArray, Int32 length )
{
sourceArray.ThrowIfNull( nameof( sourceArray ) );
destinationArray.ThrowIfNull( nameof( destinationArray ) );
Array.Copy( sourceArray, destinationArray, length );
}