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


C# Solution.OrderBy方法代码示例

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


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

示例1: TestMethod

 public void TestMethod(string s, string expectedResultString)
 {
     expectedResultString = JsonConvert.SerializeObject(JsonConvert.DeserializeObject<string[]>(expectedResultString).OrderBy(ip => ip));
     var answer = new Solution().RestoreIpAddresses(s);
     var answerString = JsonConvert.SerializeObject(answer.OrderBy(ip => ip));
     Assert.AreEqual(expectedResultString, answerString);
 }
开发者ID:alexguo88,项目名称:LeetCode,代码行数:7,代码来源:93.RestoreIPAddresses.Test.cs

示例2: TestMethod1

 public void TestMethod1(string numsString, string expectedresultString)
 {
     var nums = JsonConvert.DeserializeObject<int[]>(numsString);
     expectedresultString = JsonConvert.SerializeObject(JsonConvert.DeserializeObject<int[]>(expectedresultString).OrderBy(i => i));
     var result = new Solution().MajorityElement(nums);
     Assert.AreEqual(expectedresultString, JsonConvert.SerializeObject(result.OrderBy(i => i)));
 }
开发者ID:alexguo88,项目名称:LeetCode,代码行数:7,代码来源:229.MajorityElementII.Test.cs

示例3: Test

    public void Test(string boardString, string wordsString, string expectedFoundWordsString)
    {
        var board = JsonConvert.DeserializeObject<char[,]>(boardString);

        var words = JsonConvert.DeserializeObject<string[]>(wordsString);
        var expectedFoundWords = JsonConvert.DeserializeObject<string[]>(expectedFoundWordsString);

        var answer = new Solution().FindWords(board, words);
        Assert.AreEqual(JsonConvert.SerializeObject(expectedFoundWords.OrderBy(w => w)), JsonConvert.SerializeObject(answer.OrderBy(w => w)));
    }
开发者ID:alexguo88,项目名称:LeetCode,代码行数:10,代码来源:212.WordSearchII.Test.cs

示例4: TestMethod

 public void TestMethod(int maxLength, int min, int max, int repeatTimes)
 {
     Repeat(repeatTimes, () =>
     {
         var nums = GenerateIntegerArray(0, maxLength, min, max);
         var target = Random.Next(min * nums.Length, (max + 1) * nums.Length);
         var expectedResult = FourSum(nums, target);
         var expectedResultString = JsonConvert.SerializeObject(expectedResult.OrderBy(x => string.Join(",", x)));
         var result = new Solution().FourSum(nums, target);
         var resultString = JsonConvert.SerializeObject(result.OrderBy(x => string.Join(",", x)));
         Assert.AreEqual(expectedResultString, resultString, string.Format("nums: {0}. target: {1}.", JsonConvert.SerializeObject(nums), target));
     });
 }
开发者ID:alexguo88,项目名称:LeetCode,代码行数:13,代码来源:18.4Sum.Test.cs

示例5: TestMethod

 public void TestMethod(string s, string expectedResultString)
 {
     expectedResultString = JsonConvert.SerializeObject(JsonConvert.DeserializeObject<IList<string>>(expectedResultString).OrderBy(dna => dna));
     var answer = new Solution().FindRepeatedDnaSequences(s);
     Assert.AreEqual(expectedResultString, JsonConvert.SerializeObject(answer.OrderBy(dna => dna)));
 }
开发者ID:alexguo88,项目名称:LeetCode,代码行数:6,代码来源:187.RepeatedDnaSequences.Test.cs

示例6: TestMethod1

 public void TestMethod1(string num, int target, string expectedResultString)
 {
     expectedResultString = JsonConvert.SerializeObject(JsonConvert.DeserializeObject<IList<string>>(expectedResultString).OrderBy(x => x));
     var results = new Solution().AddOperators(num, target);
     Assert.AreEqual(expectedResultString, JsonConvert.SerializeObject(results.OrderBy(x => x)));
 }
开发者ID:alexguo88,项目名称:LeetCode,代码行数:6,代码来源:282.ExpressionAddOperators.Test.cs


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