本文整理汇总了C#中Array.GetLowerBound方法的典型用法代码示例。如果您正苦于以下问题:C# Array.GetLowerBound方法的具体用法?C# Array.GetLowerBound怎么用?C# Array.GetLowerBound使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Array
的用法示例。
在下文中一共展示了Array.GetLowerBound方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyTo
public void CopyTo (Array array, int index)
{
if (array == null)
throw new ArgumentNullException("array");
if ((index < array.GetLowerBound (0)) || (index > array.GetUpperBound (0)))
throw new ArgumentOutOfRangeException("index");
// is the check for IsFixedSize required?
if ((array.IsFixedSize) || (index + this.Count > array.GetUpperBound (0)))
throw new ArgumentException("array");
((OleDbError[]) (items.ToArray ())).CopyTo (array, index);
}
示例2: CopyTo
/// <overload>
/// <para>Copies the <see cref='System.Management.PropertyDataCollection'/> into an array.</para>
/// </overload>
/// <summary>
/// <para>Copies the <see cref='System.Management.PropertyDataCollection'/> into an array.</para>
/// </summary>
/// <param name='array'>The array to which to copy the <see cref='System.Management.PropertyDataCollection'/>. </param>
/// <param name='index'>The index from which to start copying. </param>
public void CopyTo(Array array, Int32 index)
{
if (null == array)
throw new ArgumentNullException("array");
if ((index < array.GetLowerBound(0)) || (index > array.GetUpperBound(0)))
throw new ArgumentOutOfRangeException("index");
// Get the names of the properties
string[] nameArray = null;
object dummy = null;
int flag = 0;
if (isSystem)
flag |= (int)tag_WBEM_CONDITION_FLAG_TYPE.WBEM_FLAG_SYSTEM_ONLY;
else
flag |= (int)tag_WBEM_CONDITION_FLAG_TYPE.WBEM_FLAG_NONSYSTEM_ONLY;
flag |= (int)tag_WBEM_CONDITION_FLAG_TYPE.WBEM_FLAG_ALWAYS;
int status = this.parent.wbemObject.GetNames_(null, flag, ref dummy, out nameArray);
if (status >= 0)
{
if ((index + nameArray.Length) > array.Length)
throw new ArgumentException(null,"index");
foreach (string propertyName in nameArray)
array.SetValue(new PropertyData(parent, propertyName), index++);
}
if (status < 0)
{
if ((status & 0xfffff000) == 0x80041000)
ManagementException.ThrowWithExtendedInfo((ManagementStatus)status);
else
Marshal.ThrowExceptionForHR(status);
}
return;
}
示例3: GetArrayType
// Get the type of an array.
private BinaryArrayType GetArrayType(Array value, Type type)
{
int rank = type.GetArrayRank();
bool hasLowerBounds = false;
int dim;
for(dim = 0; dim < rank; ++dim)
{
if(value.GetLowerBound(dim) != 0)
{
hasLowerBounds = true;
break;
}
}
if(type.GetElementType().IsArray)
{
if(rank == 1)
{
if(hasLowerBounds)
{
return BinaryArrayType.JaggedWithLowerBounds;
}
else
{
return BinaryArrayType.Jagged;
}
}
else
{
if(hasLowerBounds)
{
return BinaryArrayType.
MultidimensionalWithLowerBounds;
}
else
{
return BinaryArrayType.Multidimensional;
}
}
}
else if(rank == 1)
{
if(hasLowerBounds)
{
return BinaryArrayType.SingleWithLowerBounds;
}
else
{
return BinaryArrayType.Single;
}
}
else
{
if(hasLowerBounds)
{
return BinaryArrayType.
MultidimensionalWithLowerBounds;
}
else
{
return BinaryArrayType.Multidimensional;
}
}
}
示例4: ArgumentNullException
void ICollection.CopyTo(Array array, int index)
{
if (array == null)
throw new ArgumentNullException(nameof(array));
if (index < 0)
throw new ArgumentOutOfRangeException(nameof(index), index, SR.ArgumentOutOfRange_NeedNonNegNum);
if (array.Rank != 1)
throw new ArgumentException(SR.Arg_MultiRank, nameof(array));
if (array.GetLowerBound(0) != 0)
throw new ArgumentException(SR.Arg_NonZeroLowerBound, nameof(array));
if (array.Length - index < _list.Count)
throw new ArgumentException(SR.Arg_InsufficientSpace);
for (DictionaryNode node = _list._head; node != null; node = node.next)
{
array.SetValue(_isKeys ? node.key : node.value, index);
index++;
}
}
示例5: CopyTo
public virtual void CopyTo (Array array, int index)
{
if (controls == null)
return;
// can't use controls.CopyTo (array, index);
// as we do not allocate it based on the true
// numbers of items we have in the collection
// so we must re-implement Array.CopyTo :(
if (array == null)
throw new ArgumentNullException ("array");
if (index + count > array.GetLowerBound (0) + array.GetLength (0))
throw new ArgumentException ();
if (array.Rank > 1)
throw new RankException (Locale.GetText ("Only single dimension arrays are supported."));
if (index < 0)
throw new ArgumentOutOfRangeException ("index", Locale.GetText ("Value has to be >= 0."));
for (int i=0; i < count; i++)
array.SetValue (controls [i], i + index);
}