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


C# System.Collections.Generic.List.ToArray方法代码示例

本文整理汇总了C#中System.Collections.Generic.List.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.Generic.List.ToArray方法的具体用法?C# System.Collections.Generic.List.ToArray怎么用?C# System.Collections.Generic.List.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Collections.Generic.List的用法示例。


在下文中一共展示了System.Collections.Generic.List.ToArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HasCast

        private static bool HasCast(Type type, Type from, Type to, out MethodInfo op)
        {
#if WINRT
            System.Collections.Generic.List<MethodInfo> list = new System.Collections.Generic.List<MethodInfo>();
            foreach (var item in type.GetRuntimeMethods())
            {
                if (item.IsStatic) list.Add(item);
            }
            MethodInfo[] found = list.ToArray();
#else
            const BindingFlags flags = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
            MethodInfo[] found = type.GetMethods(flags);
#endif
            for(int i = 0 ; i < found.Length ; i++)
            {
                MethodInfo m = found[i];
                if ((m.Name != "op_Implicit" && m.Name != "op_Explicit") || m.ReturnType != to)
                {
                    continue;
                }
                ParameterInfo[] paramTypes = m.GetParameters();
                if(paramTypes.Length == 1 && paramTypes[0].ParameterType == from)
                {
                    op = m;
                    return true;
                }
            }
            op = null;
            return false;
        }
开发者ID:baojiangtao,项目名称:CrazySlug,代码行数:30,代码来源:SurrogateSerializer.cs

示例2: unit

 static MItem unit(string Format, params string[] units)
 {
   var lUnits = new System.Collections.Generic.List<string>(units.Length);
   foreach (var unit in units)
     lUnits.Add(SMath.Manager.UnitsManager.GetCurrentUnitName(unit));
   return Converter.ToMItem(string.Format(Format, lUnits.ToArray()));
 }
开发者ID:saha84,项目名称:CoolProp,代码行数:7,代码来源:Unit.cs

示例3: Start

 // Use this for initialization
 void Start()
 {
     buffSpawnPositions = GetComponentsInChildren<Transform> ();
     System.Collections.Generic.List<Transform> list = new System.Collections.Generic.List<Transform> (buffSpawnPositions);
     list.Remove (transform);
     buffSpawnPositions = list.ToArray ();
 }
开发者ID:vankovilija,项目名称:everyoneisafriend,代码行数:8,代码来源:SpawnBuff.cs

示例4: SubReader

		/// <summary> Returns sub-reader subIndex from reader.
		/// 
		/// </summary>
		/// <param name="reader">parent reader
		/// </param>
		/// <param name="subIndex">index of desired sub reader
		/// </param>
		/// <returns> the subreader at subINdex
		/// </returns>
		public static IndexReader SubReader(IndexReader reader, int subIndex)
		{
            var subReadersList = new System.Collections.Generic.List<IndexReader>();
			ReaderUtil.GatherSubReaders(subReadersList, reader);
			IndexReader[] subReaders = subReadersList.ToArray();
			return subReaders[subIndex];
		}
开发者ID:modulexcite,项目名称:Xamarin-Lucene.Net,代码行数:16,代码来源:ReaderUtil.cs

示例5: RandomTest

        public void RandomTest()
        {
            RingBuffer<int> TestObject = new RingBuffer<int>(10);
            Utilities.Random.Random Rand = new Utilities.Random.Random();
            int Value = 0;
            for (int x = 0; x < 10; ++x)
            {
                Value = Rand.Next();
                TestObject.Add(Value);
                Assert.Equal(1, TestObject.Count);
                Assert.Equal(Value, TestObject.Remove());
            }
            Assert.Equal(0, TestObject.Count);
            System.Collections.Generic.List<int> Values=new System.Collections.Generic.List<int>();
            for (int x = 0; x < 10; ++x)
            {
                Values.Add(Rand.Next());
            }
            TestObject.Add(Values);
            Assert.Equal(Values.ToArray(), TestObject.ToArray());

            for (int x = 0; x < 10; ++x)
            {
                Assert.Throws<InvalidOperationException>(() => TestObject.Add(Rand.Next()));
                Assert.Equal(10, TestObject.Count);
            }
        }
开发者ID:kaytie,项目名称:Craig-s-Utility-Library,代码行数:27,代码来源:RingBuffer.cs

示例6: ReadZeroTerminatedString

 private static string ReadZeroTerminatedString(Stream stream)
 {
     byte[] buf1 = new byte[1];
     var list = new System.Collections.Generic.List<byte>();
     bool done = false;
     do
     {
         // workitem 7740
         int n = stream.Read(buf1, 0, 1);
         if (n != 1)
         {
             throw new ZlibException("Unexpected EOF reading GZIP header.");
         }
         if (buf1[0] == 0)
         {
             done = true;
         }
         else
         {
             list.Add(buf1[0]);
         }
     } while (!done);
     byte[] a = list.ToArray();
     return ArchiveEncoding.Default.GetString(a, 0, a.Length);
 }
开发者ID:RickyLin,项目名称:sharpcompress,代码行数:25,代码来源:GZipFilePart.cs

示例7: BlockTag

		private void BlockTag(string tag, IDictionary attributes, ICallable block)
		{
			Output.Write("<{0}", tag);

			System.Collections.Generic.List<string> attributeValues = new System.Collections.Generic.List<string>();

			if (null != attributes)
			{
				foreach(DictionaryEntry entry in attributes)
				{
					attributeValues.Add(string.Format("{0}=\"{1}\"", entry.Key, entry.Value));
				}
			}

			if (0 != attributeValues.Count)
			{
				Output.Write(" ");
				Output.Write(string.Join(" ", attributeValues.ToArray()));
			}

			Output.Write(">");
			if (block != null)
			{
				block.Call(null);
			}
			Output.Write("</{0}>", tag);
		}
开发者ID:ralescano,项目名称:castle,代码行数:27,代码来源:HtmlExtension.cs

示例8: _Export

    void _Export(string path,GameObject obj)
    {
        var bcs = obj.GetComponentsInChildren<BoxCollider>();
        System.Collections.Generic.List<Regulus.Utility.OBB> obbs = new System.Collections.Generic.List<Regulus.Utility.OBB>();
        foreach (var bc in bcs)
        {

            float x = bc.gameObject.transform.position.x;
            //float x = bc.bounds.center.x;
            float y = bc.gameObject.transform.position.z;
            //float y = bc.bounds.center.z;
            float w = bc.gameObject.transform.localScale.x * bc.size.x;
            //float w = bc.bounds.size.x;
            float h = bc.gameObject.transform.localScale.z * bc.size.z;
            //float h = bc.bounds.size.z;
            float r = bc.gameObject.transform.rotation.eulerAngles.y;

            Debug.Log("x" + x + " " + "y" + y + " " + "w" + w + " " + "h" + h + " " + "r" + r + " ");
            var obb = new Regulus.Utility.OBB(x,y,w,h);
            obb.setRotation(r);
            obbs.Add(obb);
        }
        Debug.Log("Expoty obb count : " + obbs.Count );
        Regulus.Utility.OBB.Write(path, obbs.ToArray());
    }
开发者ID:jiowchern,项目名称:TurnBasedRPG,代码行数:25,代码来源:ExportCollider.cs

示例9: GetErrors

		ErrorInfo[] GetErrors (Document doc)
		{
			System.Collections.Generic.List<ErrorInfo> list = new System.Collections.Generic.List<ErrorInfo> ();
			foreach (ParserException pe in doc.ParseErrors)
				list.Add (new ErrorInfo (pe.Line, pe.Column, pe.Message));
			return list.Count == 0? null : list.ToArray ();
		}
开发者ID:TheRealDuckboy,项目名称:mono-soc-2008,代码行数:7,代码来源:CssAddinParser.cs

示例10: BuildUri

        internal override string BuildUri(string baseUri, string accesskey)
        {
            // assume no batch id nor events
            string usingBatch = String.Empty;
            string usingEvents = String.Empty;

            // if the user has passed a batch id, build that portion of the query string request
            if (!String.IsNullOrEmpty(BatchId))
            {
                usingBatch = String.Format("&batchid={0}", HttpUtility.UrlEncode(BatchId));
            }

            // if the user has passed event ids, build that portion of the query string request
            if (EventIds != null)
            {
                if (EventIds.Count() != 0)
                {
                    // URLEncode each event id
                    System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>();
                    foreach (var ev in EventIds)
                    {
                        list.Add(HttpUtility.UrlEncode(ev));
                    }

                    // Build the event ids string
                    string idString = String.Join("_", list.ToArray());
                    usingEvents = String.Format("&eventids={0}", idString);
                }
            }

            // build the uri
            return String.Concat(baseUri, String.Format(c_removeeventscommand, accesskey, usingBatch, usingEvents));

        }
开发者ID:Sandeep136,项目名称:JetstreamSDK-.NET,代码行数:34,代码来源:RemoveEventsRequest.cs

示例11: AttrToString

        private static string AttrToString(object attr)
        {
            object multivaluedAttribute = attr;
            if (!(multivaluedAttribute is IEnumerable) || multivaluedAttribute is byte[] || multivaluedAttribute is string)
                multivaluedAttribute = new Object[1] { multivaluedAttribute };

            System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>();

            foreach (object attribute in (IEnumerable)multivaluedAttribute)
            {
                if (attribute == null)
                {
                    list.Add(string.Empty);
                }
                else if (attribute is byte[])
                {
                    byte[] bytes = (byte[])attribute;
                    list.Add(BytesToString(bytes));
                }
                else
                {
                    list.Add(attribute.ToString());
                }
            }

            return string.Join("|", list.ToArray());
        }
开发者ID:tablesmit,项目名称:task-scheduler-managed-wrapper,代码行数:27,代码来源:HelperMethods.cs

示例12: GetRefreshRates

 public static int[] GetRefreshRates(int width, int height) {
     System.Collections.Generic.List<int> rates=new System.Collections.Generic.List<int>();
     foreach(DisplayMode ds in d3d.Adapters[adapter].GetDisplayModes(Format.X8R8G8B8)) {
         if(ds.Width==width && ds.Height==height) rates.Add(ds.RefreshRate);
     }
     return rates.ToArray();
 }
开发者ID:mdmallardi,项目名称:MGE-XE,代码行数:7,代码来源:DXMain.cs

示例13: CreateInstanceData

 protected override Neo.ApplicationFramework.Common.Alias.Entities.AliasInstancesCF CreateInstanceData()
 {
     System.Collections.Generic.List<Neo.ApplicationFramework.Common.Alias.Entities.AliasInstanceCF> instanceList = new System.Collections.Generic.List<Neo.ApplicationFramework.Common.Alias.Entities.AliasInstanceCF>(1);
     instanceList.Add(this.CreateInstanceData_Default());
     Neo.ApplicationFramework.Common.Alias.Entities.AliasInstancesCF aliasInstances = new Neo.ApplicationFramework.Common.Alias.Entities.AliasInstancesCF();
     aliasInstances.Instances = instanceList.ToArray();
     return aliasInstances;
 }
开发者ID:xukangmin,项目名称:Graftel_LRM_1402,代码行数:8,代码来源:popWrongPasscode.cs

示例14: ToBytes

 public byte[] ToBytes()
 {
     System.Collections.Generic.List<byte> dataBuffer = new System.Collections.Generic.List<byte>();
     dataBuffer.AddRange(TypeMarshal.ToBytes<ushort>((ushort)(this.BlockT.blockType)));
     dataBuffer.AddRange(TypeMarshal.ToBytes<uint>(this.BlockT.blockLen));
     dataBuffer.AddRange(TypeMarshal.ToBytes<byte>(this.numChannels));
     dataBuffer.AddRange(TypeMarshal.ToBytes<TS_RFX_CHANNELT>(this.channels[0]));
     return dataBuffer.ToArray();
 }
开发者ID:yazeng,项目名称:WindowsProtocolTestSuites,代码行数:9,代码来源:TS_RFX_CHANNELS.cs

示例15: GetRange

 /// <summary>
 /// Gets values from range
 /// </summary>
 /// <param name="fromIndex">int - startindex - including</param>
 /// <param name="toIndex">int - stop index - including</param>
 /// <returns>double[] - values from given range</returns>
 public double[] GetRange(int fromIndex, int toIndex)
 {
     System.Collections.Generic.List<double> values = new System.Collections.Generic.List<double>();
     for (int i = fromIndex; i <= toIndex; i++)
     {
         values.Add(this.Data[0][i]);
     }
     return values.ToArray();
 }
开发者ID:DrZeil,项目名称:nbn-csharp,代码行数:15,代码来源:VectorHorizontal.cs


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