当前位置: 首页>>代码示例>>C#>>正文


C# Array.SetValue方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:ExpressOS,项目名称:third_party-korlib,代码行数:10,代码来源:Array.cs

示例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++);
					}
				}
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:18,代码来源:Evidence.cs

示例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);
            }
        }
开发者ID:svcgany1,项目名称:corefx,代码行数:14,代码来源:RegexCaptureCollection.cs

示例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);
				}
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:14,代码来源:GenericAcl.cs

示例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++;
            }
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:17,代码来源:OidCollection.cs

示例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++);
			}
		}
开发者ID:runefs,项目名称:Marvin,代码行数:24,代码来源:SortedList.cs

示例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++;
                }
            }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:11,代码来源:SpnDictionary.cs

示例8:

			void ICollection.CopyTo(Array dest, int index)
			{
				for (int imageIndex = 0; imageIndex < this.Count; imageIndex++)
					dest.SetValue (this[imageIndex], index++);
			}
开发者ID:carrie901,项目名称:mono,代码行数:5,代码来源:ImageList.cs

示例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++);
                }
            }
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:19,代码来源:Hashtable.cs

示例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);
                }                
            }
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:32,代码来源:NameValueCollection.cs

示例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);
				}
			}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:8,代码来源:OrderedDictionary.cs

示例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);
			}
		}
开发者ID:runefs,项目名称:Marvin,代码行数:20,代码来源:Stack.cs

示例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++;
     }
 }
开发者ID:l1183479157,项目名称:coreclr,代码行数:15,代码来源:ListDictionaryInternal.cs

示例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++;
     }
 }
开发者ID:ArildF,项目名称:masters,代码行数:10,代码来源:listdictionary.cs

示例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++;
     }
 }
开发者ID:ArildF,项目名称:masters,代码行数:14,代码来源:listdictionary.cs


注:本文中的Array.SetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。