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


C# System.Linq.ToList方法代码示例

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


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

示例1: Does_support_Sql_In_on_int_collections

        public void Does_support_Sql_In_on_int_collections()
        {
            var ids = new[] { 1, 2, 3 };

            Assert.That(expr().Where(q => Sql.In(q.Id, 1, 2, 3)).WhereExpression,
                Is.EqualTo("WHERE \"Id\" IN (@0,@1,@2)"));

            Assert.That(expr().Where(q => Sql.In(q.Id, ids)).WhereExpression,
                Is.EqualTo("WHERE \"Id\" IN (@0,@1,@2)"));

            Assert.That(expr().Where(q => Sql.In(q.Id, ids.ToList())).WhereExpression,
                Is.EqualTo("WHERE \"Id\" IN (@0,@1,@2)"));

            Assert.That(expr().Where(q => Sql.In(q.Id, ids.ToList().Cast<object>())).WhereExpression,
                Is.EqualTo("WHERE \"Id\" IN (@0,@1,@2)"));
        }
开发者ID:ServiceStack,项目名称:ServiceStack.OrmLite,代码行数:16,代码来源:ExpressionTests.cs

示例2: RobotTest

        public void RobotTest()
        {
            var commands = new[]
            {
                "Move 2",
                "Turn right",
                "Move 4",
                "Turn left",
                "Move -5",
                "Turn right",
                "Move 10",
                "Turn left",
                "Move -2",
                "Turn left",
                "Turn left",
                "Move 5",
                "Move -2",
                "Turn right",
                "Move 1",
                "Move 0"
            };

            const int expectedX = 13;
            const int expectedY = -8;

            var grid = new Grid();
            var robot = new Robot(grid);
            commands.ToList().ForEach(robot.Command);

            var actualX = robot.PositionX;
            var actualY = robot.PositionY;

            Assert.AreEqual(expectedX, actualX);
            Assert.AreEqual(expectedY, actualY);
        }
开发者ID:ryanerdmann,项目名称:programming-puzzles,代码行数:35,代码来源:RobotTests.cs

示例3: Does_support_Sql_In_on_string_collections

        public void Does_support_Sql_In_on_string_collections()
        {
            var ids = new[] { "A", "B", "C" };

            Assert.That(expr().Where(q => Sql.In(q.FirstName, "A", "B", "C")).WhereExpression,
                Is.EqualTo("WHERE \"FirstName\" IN (@0,@1,@2)"));

            Assert.That(expr().Where(q => Sql.In(q.FirstName, ids)).WhereExpression,
                Is.EqualTo("WHERE \"FirstName\" IN (@0,@1,@2)"));

            Assert.That(expr().Where(q => Sql.In(q.FirstName, ids.ToList())).WhereExpression,
                Is.EqualTo("WHERE \"FirstName\" IN (@0,@1,@2)"));

            Assert.That(expr().Where(q => Sql.In(q.FirstName, ids.ToList().Cast<object>())).WhereExpression,
                Is.EqualTo("WHERE \"FirstName\" IN (@0,@1,@2)"));
        }
开发者ID:ServiceStack,项目名称:ServiceStack.OrmLite,代码行数:16,代码来源:ExpressionTests.cs

示例4: EnableConversations

        private void EnableConversations()
        {
            var itemstoEngage = new[] 
            {
                By.CssSelector("#yucs-help_button"), 
                By.CssSelector("#yucs-help_button"), // has to be clicked twice to respond
                By.XPath("//a[@data-mad='options']"),
                By.CssSelector("li[data-name='viewing_email'] a"),
                By.CssSelector("#options-enableConv"),
                By.XPath("//div[contains(@class, 'modal-settings')]//button[contains(text(), 'Save')]")
            };

            Delay();
            itemstoEngage.ToList().ForEach(it => 
            {
                Driver.RepeatFindAndExecuteAction
                (
                    () => Driver.FindElements(it).FirstOrDefault(x => x.IsDisplayed()),

                    el =>
                    {
                        el.Click();
                    },

                    () => Delay(),
                    WebDriverDefaults.NumberOfRetriesForStaleExceptions
                );
            });
        }
开发者ID:c0d3m0nky,项目名称:mty,代码行数:29,代码来源:EnableFromDisplayInList.cs

示例5: SendNotificationEmail

        public void SendNotificationEmail()
        {
            var sender = CreateSender();
            var reader = new ArticleReader();
            var articles = new[] { reader.Read(new FileResources().Read("http://t/3530")) };

            sender.Send(articles.ToList());
        }
开发者ID:jonvanleuven,项目名称:DeCorrespondent,代码行数:8,代码来源:EmailNotificationSenderTest.cs

示例6: Absent_elements_should_be_included_in_result

        public void Absent_elements_should_be_included_in_result()
        {
            var source = new[] { 6, 10, 5, 1 };

            var sortedSource = _sort.Sort(source.ToList()).ToArray();
            var filledSource = _filler.Fill(sortedSource);

            Ass.Equal(new[] { 1, 2, 3, 4, 5, 6, 7 ,8, 9, 10 }, filledSource);
        }
开发者ID:rnofenko,项目名称:devPuzzle,代码行数:9,代码来源:EnumerationHoleTests.cs

示例7: Absent_elements_should_be_displayed_in_result

        public void Absent_elements_should_be_displayed_in_result()
        {
            var source = new[] { 6, 10, 5, 1, 12 };

            var sortedSource = _sort.Sort(source.ToList()).ToArray();
            var foundResults = _finder.Find(sortedSource);

            Ass.Equal(new[] { "2-4", "7-9", "11" }, foundResults);
        }
开发者ID:rnofenko,项目名称:devPuzzle,代码行数:9,代码来源:EnumerationHoleTests.cs

示例8: GetRangeTest

 public void GetRangeTest([Values(0, 1)]int version, [Values(0, 1)]int count)
 {
     var aggregate = new EventAggregate();
     var events = new[] { "a", "b", "c" };
     using (var tran = aggregate.BeginTransaction())
     {
         aggregate.PushMany(-1, events);
         tran.Commit();
     }
     CollectionAssert.AreEqual(events.ToList().GetRange(version, count), aggregate.GetRange(version, count));
 }
开发者ID:eleks,项目名称:FloatingQueuePoC,代码行数:11,代码来源:EventAggregateTests.cs

示例9: ParseFileTest

 public void ParseFileTest()
 {
     // arrange 
     var columns = new[] { "Column1", "Column2", "Column3" };
     // act
     var line = CsvUtil.ParseFile("TestData\\parsefile.csv", true).First();
     // assert            
     columns.ToList().ForEach(
         col =>
         {
             Assert.IsTrue(line.Any(l => l.Key == col));
         });
 }
开发者ID:codingfreak,项目名称:cfUtils,代码行数:13,代码来源:CsvUtilTests.cs

示例10: LoadQuestions

        private void LoadQuestions()
        {
            var questions = new[]
            {
                new Question
                {
                    QuestionText = "Who didn't engineer the Apple Computer 1?",
                    Statements = new[] {"Bill Gates", "Steve Jobs", "Steve Wozniak", ""},
                    CorrectIndex = 2
                }
            };

            var qd = new QuestionDatabase { Questions = questions.ToList() };
            XML.Serialize(qd, "Data/questions.xml");

            database = XML.Deserialize<QuestionDatabase>("Data/questions.xml");
        }
开发者ID:Herbstein,项目名称:GetItWrong,代码行数:17,代码来源:MainWindow.xaml.cs

示例11:

    public void TestReactΔ()
    {
      var f = new MapFunction<int, int>(x => x + 1);

      var numbers = new[] {10, 7, 12, 13, 6};

      var value = f[numbers];

      Assert.That(f.React(value, numbers.ToList().ToLog(Δ1.Empty)).Δ, Is.EqualTo(Δ1.Empty));
      Assert.That(f.React(value, numbers.ToList().Mutate(Expressions.Numbers(4).ToIns(), (key, i) => 26)).Δ, Is.EqualTo(Expressions.Numbers(4).ToIns()));
      Assert.That(f.React(value, numbers.ToList().Mutate(Expressions.Numbers(4).ToIns(), (key, i) => 13)).Δ, Is.EqualTo(Expressions.Numbers(4).ToIns()));
      Assert.That(f.React(value, numbers.ToList().Mutate(Expressions.Numbers(5).ToIns(), (key, i) => 26)).Δ, Is.EqualTo(Expressions.Numbers(5).ToIns()));
      Assert.That(f.React(value, numbers.ToList().Mutate(Expressions.Numbers(5).ToIns(), (key, i) => 7)).Δ, Is.EqualTo(Expressions.Numbers(5).ToIns()));
      Assert.That(f.React(value, numbers.ToList().Mutate(Expressions.Numbers(1).ToDel(), (key, i) => 26)).Δ, Is.EqualTo(Expressions.Numbers(1).ToDel()));
      Assert.That(f.React(value, numbers.ToList().Mutate(Expressions.Numbers(3).ToDel(), (key, i) => 26)).Δ, Is.EqualTo(Expressions.Numbers(3).ToDel()));
    }
开发者ID:rbec,项目名称:malbec,代码行数:16,代码来源:TestMapFunction.cs

示例12: TestWithOneSetContainingUniverse

        public void TestWithOneSetContainingUniverse()
        {
            var universe = new[] { 1, 2, 3, 4, 5 };
            var sets = new[]
            {
                new[] { 1, 2, 3, 4, 5 },
                new[] { 2, 3, 4, 5 },
                new[] { 5 },
                new[] { 3 }
            };

            var selectedSets = SetCover.ChooseSets(sets.ToList(), universe.ToList());

            var expectedResult = new[]
            {
                sets[0]
            };

            CollectionAssert.AreEqual(expectedResult, selectedSets);
        }
开发者ID:EBojilova,项目名称:Algorithms-CSharp,代码行数:20,代码来源:SetCoverTests.cs

示例13: TestWithAllSetsNeeded

        public void TestWithAllSetsNeeded()
        {
            var universe = new[] { 1, 2, 3, 4, 5 };
            var sets = new[]
            {
                new[] { 1, 3, 5 },
                new[] { 1, 2 },
                new[] { 3, 4 }
            };

            var selectedSets = SetCover.ChooseSets(sets.ToList(), universe.ToList());

            var expectedResult = new[]
            {
                sets[0],
                sets[1],
                sets[2]
            };

            CollectionAssert.AreEqual(expectedResult, selectedSets);
        }
开发者ID:EBojilova,项目名称:Algorithms-CSharp,代码行数:21,代码来源:SetCoverTests.cs

示例14: TestWithNoRedundantElements

        public void TestWithNoRedundantElements()
        {
            var universe = new[] { 1, 2, 3, 4, 5 };
            var sets = new[]
            {
                new[] { 1 },
                new[] { 2, 4 },
                new[] { 5 },
                new[] { 3 }
            };

            var selectedSets = SetCover.ChooseSets(sets.ToList(), universe.ToList());

            var expectedResult = new[]
            {
                sets[1],
                sets[0],
                sets[2],
                sets[3]
            };

            CollectionAssert.AreEqual(expectedResult, selectedSets);
        }
开发者ID:EBojilova,项目名称:Algorithms-CSharp,代码行数:23,代码来源:SetCoverTests.cs

示例15: TestWithSeveralRedundantSets

        public void TestWithSeveralRedundantSets()
        {
            var universe = new[] { 1, 2, 3, 4, 5, 6 };
            var sets = new[]
            {
                new[] { 1, 2, 5 },
                new[] { 2, 3, 5 },
                new[] { 3, 4, 5 },
                new[] { 4, 5 },
                new[] { 1, 3, 4, 6 }
            };

            var selectedSets = SetCover.ChooseSets(sets.ToList(), universe.ToList());

            var expectedResult = new[]
            {
                sets[4],
                sets[0]
            };

            CollectionAssert.AreEqual(expectedResult, selectedSets);
        }
开发者ID:EBojilova,项目名称:Algorithms-CSharp,代码行数:22,代码来源:SetCoverTests.cs


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