本文整理汇总了C#中Array.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Array.SetValue方法的具体用法?C# Array.SetValue怎么用?C# Array.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Array
的用法示例。
在下文中一共展示了Array.SetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Copy
/// <summary>
///
/// </summary>
public static void Copy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length)
{
for (int s = 0, d = destinationIndex; s < length; s++, d++)
{
sourceArray.SetValue(destinationArray.GetValue(d), s + sourceIndex);
}
}
示例2: CopyTo
// Implement the ICollection interface.
public void CopyTo(Array array, int index)
{
if(hostEvidence != null)
{
foreach(Object o1 in hostEvidence)
{
array.SetValue(o1, index++);
}
}
if(assemblyEvidence != null)
{
foreach(Object o2 in assemblyEvidence)
{
array.SetValue(o2, index++);
}
}
}
示例3: ArgumentNullException
/// <summary>
/// Copies all the elements of the collection to the given array
/// beginning at the given index.
/// </summary>
void ICollection.CopyTo(Array array, int arrayIndex)
{
if (array == null)
throw new ArgumentNullException("array");
for (int i = arrayIndex, j = 0; j < Count; i++, j++)
{
array.SetValue(this[j], i);
}
}
示例4: ArgumentNullException
// Implement the ICollection interface.
void ICollection.CopyTo(Array array, int index)
{
if(array == null)
{
throw new ArgumentNullException("array");
}
int count = Count;
int posn;
for(posn = 0; posn < count; ++posn)
{
array.SetValue(this[posn], index + posn);
}
}
示例5: ArgumentNullException
void ICollection.CopyTo(Array array, int index)
{
if (array == null)
throw new ArgumentNullException(nameof(array));
if (array.Rank != 1)
throw new ArgumentException(SR.Arg_RankMultiDimNotSupported);
if (index < 0 || index >= array.Length)
throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index);
if (index + Count > array.Length)
throw new ArgumentException(SR.Argument_InvalidOffLen);
for (int i = 0; i < Count; i++)
{
array.SetValue(this[i], index);
index++;
}
}
示例6: CopyTo
// ICollection
public virtual void CopyTo (Array array, int arrayIndex)
{
if (null == array)
throw new ArgumentNullException();
if (arrayIndex < 0)
throw new ArgumentOutOfRangeException();
if (array.Rank > 1)
throw new ArgumentException("array is multi-dimensional");
if (arrayIndex >= array.Length)
throw new ArgumentNullException("arrayIndex is greater than or equal to array.Length");
if (Count > (array.Length - arrayIndex))
throw new ArgumentNullException("Not enough space in array from arrayIndex to end of array");
IDictionaryEnumerator it = GetEnumerator ();
int i = arrayIndex;
while (it.MoveNext ()) {
array.SetValue (it.Entry, i++);
}
}
示例7: CopyTo
public void CopyTo(Array array, int index)
{
CheckCopyToArguments(array, index, Count);
int offset = 0;
foreach (object entry in this)
{
array.SetValue(entry, offset + index);
offset++;
}
}
示例8:
void ICollection.CopyTo(Array dest, int index)
{
for (int imageIndex = 0; imageIndex < this.Count; imageIndex++)
dest.SetValue (this[imageIndex], index++);
}
示例9: CopyEntries
// Copies the keys of this hashtable to a given array starting at a given
// index. This method is used by the implementation of the CopyTo method in
// the KeyCollection class.
private void CopyEntries(Array array, int arrayIndex)
{
Contract.Requires(array != null);
Contract.Requires(array.Rank == 1);
bucket[] lbuckets = _buckets;
for (int i = lbuckets.Length; --i >= 0;)
{
Object keyv = lbuckets[i].key;
if ((keyv != null) && (keyv != _buckets))
{
DictionaryEntry entry = new DictionaryEntry(keyv, lbuckets[i].val);
array.SetValue(entry, arrayIndex++);
}
}
}
示例10: CopyTo
public void CopyTo(Array dest, int index) {
if (dest==null) {
throw new ArgumentNullException("dest");
}
if (dest.Rank != 1) {
throw new ArgumentException(SR.GetString(SR.Arg_MultiRank));
}
if (index < 0) {
throw new ArgumentOutOfRangeException("index",SR.GetString(SR.IndexOutOfRange, index.ToString(CultureInfo.CurrentCulture)) );
}
if (dest.Length - index < Count) {
throw new ArgumentException(SR.GetString(SR.Arg_InsufficientSpace));
}
int n = Count;
if (_all == null) {
String[] all = new String[n];
for (int i = 0; i < n; i++) {
all[i] = Get(i);
dest.SetValue( all[i], i + index);
}
_all = all; // wait until end of loop to set _all reference in case Get throws
}
else {
for (int i = 0; i < n; i++) {
dest.SetValue( _all[i], i + index);
}
}
}
示例11: CopyTo
public void CopyTo (Array array, int index)
{
for (int n=0; n<list.Count; n++) {
DictionaryEntry de = (DictionaryEntry) list [n];
if (isKeyList) array.SetValue (de.Key, index + n);
else array.SetValue (de.Value, index + n);
}
}
示例12: CopyTo
public virtual void CopyTo (Array array, int index) {
if (array == null) {
throw new ArgumentNullException("array");
}
if (index < 0) {
throw new ArgumentOutOfRangeException("index");
}
if (array.Rank > 1 ||
array.Length > 0 && index >= array.Length ||
count > array.Length - index) {
throw new ArgumentException();
}
for (int i = current; i != -1; i--) {
array.SetValue(contents[i],
count - (i + 1) + index);
}
}
示例13: ArgumentNullException
void ICollection.CopyTo(Array array, int index) {
if (array==null)
throw new ArgumentNullException("array");
if (array.Rank != 1)
throw new ArgumentException(Environment.GetResourceString("Arg_RankMultiDimNotSupported"));
if (index < 0)
throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
Contract.EndContractBlock();
if (array.Length - index < list.Count)
throw new ArgumentException(Environment.GetResourceString("ArgumentOutOfRange_Index"), "index");
for (DictionaryNode node = list.head; node != null; node = node.next) {
array.SetValue(isKeys ? node.key : node.value, index);
index++;
}
}
示例14: ArgumentNullException
void ICollection.CopyTo(Array array, int index) {
if (array==null)
throw new ArgumentNullException("array");
if (index < 0)
throw new ArgumentOutOfRangeException("index", SR.GetString(SR.ArgumentOutOfRange_NeedNonNegNum));
for (DictionaryNode node = list.head; node != null; node = node.next) {
array.SetValue(isKeys ? node.key : node.value, index);
index++;
}
}
示例15: CopyTo
/// <include file='doc\ListDictionary.uex' path='docs/doc[@for="ListDictionary.CopyTo"]/*' />
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
public void CopyTo(Array array, int index) {
if (array==null)
throw new ArgumentNullException("array");
if (index < 0)
throw new ArgumentOutOfRangeException("index", SR.GetString(SR.ArgumentOutOfRange_NeedNonNegNum));
for (DictionaryNode node = head; node != null; node = node.next) {
array.SetValue(new DictionaryEntry(node.key, node.value), index);
index++;
}
}