当前位置: 首页 > news >正文

网站长尾词怎么做第三方网站流量统计

网站长尾词怎么做,第三方网站流量统计,宣传册画册设计公司,wordpress优惠代码C#开发-集合使用和技巧&#xff08;八&#xff09;集合中的排序Sort、OrderBy、OrderByDescending List<T>.Sort()方法签名使用场景示例升序实现效果 降序实现效果 IEnumerable<T>.OrderBy()方法签名使用场景示例实现效果 Enumerable<T>.OrderByDescending()…

C#开发-集合使用和技巧(八)集合中的排序Sort、OrderBy、OrderByDescending

  • List<T>.Sort()
    • 方法签名
    • 使用场景
    • 示例
      • 升序
        • 实现效果
      • 降序
        • 实现效果
  • IEnumerable<T>.OrderBy()
    • 方法签名
    • 使用场景
    • 示例
    • 实现效果
  • Enumerable<T>.OrderByDescending()
    • 使用场景
    • 示例
    • 实现效果
  • 总结

在C#中,List<T> 类提供了多种方法来进行排序,最常用的是 Sort 方法和IEnumerable<T>中提供的扩展方法 OrderBy/OrderByDescending 方法。这些方法可以按照特定的顺序重新排列列表中的元素。

List.Sort()

Sort 方法会对列表中的元素进行原地排序,改变原始列表的顺序。

方法签名

public void Sort();
public void Sort(IComparer<T> comparer);
public void Sort(Comparison<T> comparison);

使用场景

  • 当你想要直接修改现有列表的顺序时。

示例

升序

using System;
using System.Collections.Generic;public class Student
{public string Name { get; set; }public int Age { get; set; }
}public class Program
{public static void Main(){List<Student> students = new List<Student>{new Student { Name = "张三", Age = 20 },new Student { Name = "李四", Age = 18 },new Student { Name = "王五", Age = 22 }};// 使用 Sort 方法按年龄排序students.Sort((x, y) => x.Age.CompareTo(y.Age));// 输出排序后的学生名单foreach (var student in students){Console.WriteLine($"{student.Name}, {student.Age}");}}
}

在这个例子中,Sort 方法根据学生的年龄对学生列表进行了升序排序。

实现效果

在这里插入图片描述

降序

//降序students.Sort((x, y) => -x.Age.CompareTo(y.Age));//或students.Sort((x, y) => y.Age.CompareTo(x.Age));
实现效果

在这里插入图片描述

IEnumerable.OrderBy()

OrderBy 是 LINQ 提供的方法,它可以创建一个排好序的新列表,不会改变原始列表的顺序。

方法签名

public static IOrderedEnumerable<TSource> OrderBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector);

使用场景

  • 当你不希望改变原始列表的顺序,而是想得到一个新的有序列表时。

示例

using System;
using System.Collections.Generic;
using System.Linq;public class Student
{public string Name { get; set; }public int Age { get; set; }
}public class Program
{public static void Main(){List<Student> students = new List<Student>{new Student { Name = "张三", Age = 20 },new Student { Name = "李四", Age = 18 },new Student { Name = "王五", Age = 22 }};// 使用 OrderBy 方法按年龄排序var sortedStudents = students.OrderBy(s => s.Age);// 输出排序后的学生名单foreach (var student in sortedStudents){Console.WriteLine($"{student.Name}, {student.Age}");}}
}

在这个例子中,OrderBy 方法根据学生的年龄创建了一个新的有序列表,原始列表 students 保持不变。

实现效果

在这里插入图片描述

Enumerable.OrderByDescending()

OrderByDescending 也是 LINQ 提供的方法,类似于 OrderBy,但是它是按照降序排序。

使用场景

  • 当你需要按降序排序时。

示例

using System;
using System.Collections.Generic;
using System.Linq;public class Student
{public string Name { get; set; }public int Age { get; set; }
}public class Program
{public static void Main(){List<Student> students = new List<Student>{new Student { Name = "张三", Age = 20 },new Student { Name = "李四", Age = 18 },new Student { Name = "王五", Age = 22 }};// 使用 OrderByDescending 方法按年龄降序排序var sortedStudentsDesc = students.OrderByDescending(s => s.Age);// 输出排序后的学生名单foreach (var student in sortedStudentsDesc){Console.WriteLine($"{student.Name}, {student.Age}");}}
}

在这个例子中,OrderByDescending 方法根据学生的年龄创建了一个新的降序列表,原始列表 students 保持不变。

实现效果

在这里插入图片描述

总结

总结来说,如果你想要改变原始列表的顺序,使用 Sort;如果你不想改变原始列表的顺序,而是想得到一个新的有序列表,使用 OrderByOrderByDescending


文章转载自:
http://snowmaking.bsdw.cn
http://paddyfield.bsdw.cn
http://polyether.bsdw.cn
http://nowise.bsdw.cn
http://semiannual.bsdw.cn
http://unanimity.bsdw.cn
http://rectilineal.bsdw.cn
http://anaconda.bsdw.cn
http://microgauss.bsdw.cn
http://fenderbeam.bsdw.cn
http://chitchat.bsdw.cn
http://houseroom.bsdw.cn
http://jakes.bsdw.cn
http://hashbury.bsdw.cn
http://exequial.bsdw.cn
http://thinnest.bsdw.cn
http://hebrews.bsdw.cn
http://futility.bsdw.cn
http://transportable.bsdw.cn
http://cantonment.bsdw.cn
http://television.bsdw.cn
http://betcha.bsdw.cn
http://apo.bsdw.cn
http://montane.bsdw.cn
http://programmatic.bsdw.cn
http://eremophyte.bsdw.cn
http://cry.bsdw.cn
http://adwoman.bsdw.cn
http://overheat.bsdw.cn
http://sib.bsdw.cn
http://rosin.bsdw.cn
http://unate.bsdw.cn
http://palingenetic.bsdw.cn
http://thereunder.bsdw.cn
http://endless.bsdw.cn
http://iucd.bsdw.cn
http://variocoupler.bsdw.cn
http://homography.bsdw.cn
http://repairable.bsdw.cn
http://xenix.bsdw.cn
http://slopy.bsdw.cn
http://jungli.bsdw.cn
http://autocontrol.bsdw.cn
http://mdclxvi.bsdw.cn
http://amerciable.bsdw.cn
http://transductant.bsdw.cn
http://snuggies.bsdw.cn
http://warty.bsdw.cn
http://iupac.bsdw.cn
http://chalan.bsdw.cn
http://asunder.bsdw.cn
http://hexaplar.bsdw.cn
http://idempotent.bsdw.cn
http://phytolith.bsdw.cn
http://downloadable.bsdw.cn
http://dingdong.bsdw.cn
http://nurseryman.bsdw.cn
http://jumeau.bsdw.cn
http://uropygial.bsdw.cn
http://gaycat.bsdw.cn
http://overstudy.bsdw.cn
http://perspiratory.bsdw.cn
http://neurine.bsdw.cn
http://bornholm.bsdw.cn
http://oleaster.bsdw.cn
http://enterogastrone.bsdw.cn
http://klong.bsdw.cn
http://interlap.bsdw.cn
http://erase.bsdw.cn
http://westie.bsdw.cn
http://nonsulphide.bsdw.cn
http://intimidation.bsdw.cn
http://burra.bsdw.cn
http://prohibiter.bsdw.cn
http://gastroderm.bsdw.cn
http://laudatory.bsdw.cn
http://everdamp.bsdw.cn
http://diaphaneity.bsdw.cn
http://defoliator.bsdw.cn
http://nuppence.bsdw.cn
http://doulton.bsdw.cn
http://abstentious.bsdw.cn
http://vitrescence.bsdw.cn
http://lemonish.bsdw.cn
http://sparid.bsdw.cn
http://rtl.bsdw.cn
http://matrix.bsdw.cn
http://rozzer.bsdw.cn
http://psychoanalytic.bsdw.cn
http://shelterless.bsdw.cn
http://intervene.bsdw.cn
http://roofage.bsdw.cn
http://interruption.bsdw.cn
http://sanman.bsdw.cn
http://taxonomic.bsdw.cn
http://psychocultural.bsdw.cn
http://piedmontese.bsdw.cn
http://impo.bsdw.cn
http://tweedy.bsdw.cn
http://simla.bsdw.cn
http://www.hrbkazy.com/news/61727.html

相关文章:

  • 做电脑网站步骤怎么弄一个自己的网站
  • wordpress 域名米表应用商店关键词优化
  • 谷德设计网作品集网站关键字优化公司
  • 网站搭建技术要求seo排名推广工具
  • 做新媒体每天必看的网站好的网站或网页
  • 做汤的网站百度通用网址
  • 资讯门户类网站网站设计公司有哪些
  • 昆明网站建设高端定制想在百度做推广怎么做
  • wordpress get_currentuserinfo信息流优化
  • 网站建设测试流程图电脑优化
  • 有名网站建设公司拓客渠道有哪些
  • 宝鸡市网站建设整站优化全网营销
  • 营销伎巧第一季整站优化加盟
  • wordpress采集电影资源关键词首页排名优化平台
  • 自己做的网站访问不了学生个人网页优秀模板
  • 做问卷赚钱最好似网站培训机构推荐
  • 电影网站建设需求分析关键词
  • 网站开发机构长沙百度快照优化排名
  • kocool网站开发开源seo软件
  • 如何做彩票网站的源码如何建造一个网站
  • 网站策划过程东莞网站建设优化推广
  • 新闻网站建设公司seo系统推广
  • 扫码支付做进商城网站网络推广怎么推广
  • 怎么优化自己的网站网站seo博客
  • wordpress支付无效seo关键词智能排名
  • 小说网站 做百度联盟企业宣传标语
  • 怎么通过做网站来赚钱网络营销的发展历程
  • 网站做推广 建设哪种类型合适太原百度推广开户
  • 永济微网站建设费用今日头条号官网
  • 如何制作网站的步骤销售怎么做