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


C# System.ToArray方法代码示例

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


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

示例1: InsertSortTest

        public void InsertSortTest()
        {
            // Random elements
            var sorter = new InsertionSort<int>();
            sorter.Sort(shuffledList);
            var temp = shuffledList.ToArray();
            Array.Sort(temp);
            CollectionAssert.AreEqual(temp, shuffledList);

            //one element
            var collection = new[] {0};
            sorter.Sort(collection);
            temp = collection.ToArray();
            Array.Sort(temp);
            CollectionAssert.AreEqual(temp, collection);

            //zero elements
            collection = new int[0];
            sorter.Sort(collection);
            temp = collection.ToArray();
            Array.Sort(temp);
            CollectionAssert.AreEqual(temp, collection);

            //null elements
            collection = null;
            sorter.Sort(collection);
            CollectionAssert.AreEqual(null, collection);
        }
开发者ID:EvilAvenger,项目名称:AlgorithmsStudy,代码行数:28,代码来源:SortTest.cs

示例2: GetStandardValues

        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            var standardValues = new[] { NullLifetimeManagerDisplay }
                .Union(LifetimeManagerTypes.Select(x => x.Name))
                .Union(new[] {DesignResources.RegistrationLifetimeCustom});

            return new StandardValuesCollection(standardValues.ToArray());
        }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:8,代码来源:KnownLifetimeElementConverter.cs

示例3: Set

        public void Set(object target, object value, params object[] index)
        {
            IEnumerable<object> args = new[] { value };
            if (index != null) args = args.Union(index);
            if (target != null && !target.GetType().CanAssign(InternalMember.DeclaringType))
                throw new TargetException("Expected {0}".AsFormat(InternalMember.DeclaringType.GetRealClassName()));

            Cache.GetSetter(InternalMember)(target, args.ToArray());
        }
开发者ID:Trovarius,项目名称:simple,代码行数:9,代码来源:PropertyInfoWrapper.cs

示例4: BinaryToImage

        public static Image BinaryToImage(System.Data.Linq.Binary binaryData)
        {
            if (binaryData == null) return null;

            byte[] buffer = binaryData.ToArray();
            MemoryStream memStream = new MemoryStream();
            memStream.Write(buffer, 0, buffer.Length);
            return Image.FromStream(memStream);
        }
开发者ID:pippopboy,项目名称:ProjectChatApplication,代码行数:9,代码来源:Form1.cs

示例5: Union

        public Tree Union(Tree t, Edge e)
        {
            var es = new[] { e };
            es = es.Concat(Edges).ToArray();
            es = es.Concat(t.Edges).ToArray();

            var ns = Nodes.Concat(t.Nodes);

            return new Tree(ns.ToArray(), es.ToArray());
        }
开发者ID:jamesrcounts,项目名称:CS513,代码行数:10,代码来源:Tree.cs

示例6: Pipe

        public PvcPipe Pipe(string tag, Func<IEnumerable<PvcStream>, IEnumerable<PvcStream>> plugin)
        {
            IEnumerable<string> tags = new[] { tag };
            if (tag.IndexOf(',') != -1)
            {
                tags = tag.Split(',').ToList().Select(x => x.Trim());
            }

            return this.Pipe(tags.ToArray(), plugin);
        }
开发者ID:modulexcite,项目名称:pvc,代码行数:10,代码来源:PvcPipe.cs

示例7: CanSortDates

        public void CanSortDates()
        {
            var sourceArray = new[] { DateTime.MaxValue, DateTime.MinValue, DateTime.Now };
            var expected = sourceArray.ToArray();
            Array.Sort(expected);
            var sorter = DedicatedSortersFactory.CreateDedicatedSorter<DateTime>();

            sorter.Sort(sourceArray);

            CollectionAssert.AreEqual(expected, sourceArray);
        }
开发者ID:adamsitnik,项目名称:slinq,代码行数:11,代码来源:DedicatedSortersFactoryTests.cs

示例8: CanSortDoubles

        public void CanSortDoubles()
        {
            var sourceArray = new[] { 10.1, 20.2, 1.343, -4.121, 5.23, 6.5, 11.77, 3443.23 };
            var expected = sourceArray.ToArray();
            Array.Sort(expected);
            var sorter = DedicatedSortersFactory.CreateDedicatedSorter<double>();

            sorter.Sort(sourceArray);

            CollectionAssert.AreEqual(expected, sourceArray);
        }
开发者ID:adamsitnik,项目名称:slinq,代码行数:11,代码来源:DedicatedSortersFactoryTests.cs

示例9: LoadChildNodes

        public void LoadChildNodes(TreeNode node, System.Collections.Generic.IList<TreeNode> nodes)
        {
            tableNodeContainer.BeforeExpand -= tableNodeContainer_BeforeExpand;

            node.Nodes.Clear();
            node.Nodes.AddRange(nodes.ToArray());
            node.Expand();
            ShowReady();

            tableNodeContainer.BeforeExpand += tableNodeContainer_BeforeExpand;
        }
开发者ID:sujithkp,项目名称:Rex,代码行数:11,代码来源:MainForm.cs

示例10: CanSortFloats

        public void CanSortFloats()
        {
            var sourceArray = new[] { 10.1f, 20.2f, 1.343f, -4.121f, 5.23f, 6.5f, 11.77f, 3443.23f };
            var expected = sourceArray.ToArray();
            Array.Sort(expected);
            var sorter = DedicatedSortersFactory.CreateDedicatedSorter<float>();

            sorter.Sort(sourceArray);

            CollectionAssert.AreEqual(expected, sourceArray);
        }
开发者ID:adamsitnik,项目名称:slinq,代码行数:11,代码来源:DedicatedSortersFactoryTests.cs

示例11: CanSortIntegers

        public void CanSortIntegers()
        {
            var sourceArray = new[] { 10, 20, 1, -4, 5, 6, 11, 3443 };
            var expected = sourceArray.ToArray();
            Array.Sort(expected);
            var sorter = DedicatedSortersFactory.CreateDedicatedSorter<int>();

            sorter.Sort(sourceArray);

            CollectionAssert.AreEqual(expected, sourceArray);
        }
开发者ID:adamsitnik,项目名称:slinq,代码行数:11,代码来源:DedicatedSortersFactoryTests.cs

示例12: XOR_AllTrue_Multiple

        public void XOR_AllTrue_Multiple()
        {
            // Arrange
            bool result;
            var inputs = new[] { true, true, true };
            IConditionModifier modifier = new XORModifier();

            // Act
            result = modifier.IsConditionMet(true, inputs.ToArray());

            // Assert
            Assert.IsFalse(result);
        }
开发者ID:Herdo,项目名称:AdaptiveTriggerLibrary,代码行数:13,代码来源:XORModifierTest.cs

示例13: Main

        static void Main(string[] args)
        {
            var names = new[] { "Bessie", "Vashti", "Frederica", "Nisha", "Kendall", "Magdalena", "Brendon", "Eve", "Manda", "Elvera", "Miquel", "Tyra", "Lucie", "Marvella", "Tracee", "Ramiro", "Irene", "Davina", "Jeromy", "Siu" };
            //1
            Console.WriteLine("Create a list of Persons, each with one of the names");
            foreach (string s in (string[])names.ToArray())
            {
                Console.WriteLine(s);
            }
            //2
            Console.WriteLine("Create the same list then get a subset with only people whose names start with M");
            var mStarts = from s in names.ToList() where s.StartsWith("M") select s;
            foreach (string s in (string[])mStarts.ToArray())
            {
                Console.WriteLine(s);
            }

            //3
            Console.WriteLine("Create the same list then get a list everyone’s names in uppercase ");
            var upper = names.Select(x => x.ToUpper()).ToArray();
            foreach (string s in (string[])upper.ToArray())
            {
                Console.WriteLine(s);
            }
            //4
            Console.WriteLine("Create the same list then get a and array if int with the length of each name");
            foreach (string s in (string[])names.ToArray())
            {
                Console.WriteLine(s + " --> " + s.Length);
            }
            //5
            Console.WriteLine("Create the same list then get a list with only the name shortened to the first three letters ordered by name");
            var strfirst3charorder = names.Select(x => x.Substring(0, 3)).OrderBy(x => x);
            foreach (string s in (string[])strfirst3charorder.ToArray())
            {
                Console.WriteLine(s);
            }
            Console.ReadLine();
        }
开发者ID:visaldattabobba,项目名称:2013FallCSharp,代码行数:39,代码来源:Person.cs

示例14: Save

 public void Save(string file, System.IO.MemoryStream contents)
 {
     using (System.IO.IsolatedStorage.IsolatedStorageFile isoStorage = GetISOStorage())
     {
         using (var writer = new System.IO.IsolatedStorage.IsolatedStorageFileStream(file, System.IO.FileMode.Create, isoStorage))
         {
             if (contents.CanSeek && contents.Position > 0) contents.Seek(0, SeekOrigin.Begin);
             byte[] data = contents.ToArray();
             writer.Write(data, 0, data.Length);
             writer.Close();
         }
     }
 }
开发者ID:nothingmn,项目名称:zVirtualScenes-Client,代码行数:13,代码来源:IsolatedStorage.cs

示例15: Save

        public async Task<bool> Save(string file, System.IO.MemoryStream contents)
        {
            byte[] data = contents.ToArray();

            var folder = ApplicationData.Current.LocalFolder;
            var f = await folder.CreateFileAsync(file, CreationCollisionOption.ReplaceExisting);

            using (var s = await f.OpenStreamForWriteAsync())
            {
                await s.WriteAsync(data, 0, data.Length);
            }
            return true;
        }
开发者ID:nothingmn,项目名称:zVirtualScenesHub,代码行数:13,代码来源:WindowsStorage.cs


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