1. 自动属性

    public string Name { get; set; }
  2. 对象与集合的初始化
    //自动推断类型//集合的初始化
    var Products=new List<Product>{
    new Product{Name="苹果",Price=4.5M,CategoryNumber=},
    new Product{Name="橘子",Price=2.5M,CategoryNumber=},
    new Product{Name="柚子",Price=4.5M,CategoryNumber=},
    new Product{Name="西红柿",Price=3.0M,CategoryNumber=},
    new Product{Name="茄子",Price=1.5M,CategoryNumber=}
    };
    //自动推断类型//对象的初始化
    var product = new Product
    {
    Name = "苹果",
    Price = 3.7m,
    CategoryNumber =
    };
  3. 扩展方法
    1、对接口运用扩展方法
    2、创建过滤扩展方法
  4. 使用lambda表达式
    k => k.Price
  5. 使用自动类型接口
    class Program
    {
    static void Main(string[] args)
    {
    //自动推断类型
    var product = new Product
    {
    Name = "苹果",
    Price = 3.7m,
    CategoryNumber =
    };
    Console.WriteLine(product.CategoryNumber);
    }
    public class Product
    {
    public string Name { get; set; }
    public decimal Price { get; set; }
    public int CategoryNumber { get; set; }
    }
    }
  6. 使用匿名类型
    var Category = new
    {
    CategoryNumber = ,
    CategoryName = "食品"
    };
  7. 执行语言集成查询(LINQ)
    var Products=new List<Product>{
    new Product{Name="苹果",Price=4.5M,CategoryNumber=},
    new Product{Name="橘子",Price=2.5M,CategoryNumber=},
    new Product{Name="柚子",Price=4.5M,CategoryNumber=},
    new Product{Name="西红柿",Price=3.0M,CategoryNumber=},
    new Product{Name="茄子",Price=1.5M,CategoryNumber=}
    };
    //linq 查询1(查询语法)
    var pro1 = from t in Products
    orderby t.Price descending
    select new { t.Name, t.Price };
    //linq 查询2(点语法/链式语法)
    var pro2 = Products.OrderByDescending(k => k.Price).Take().Select(k => new { k.Name, k.Price });
  8. 使用Async方法
    运用async和await关键字
  9. 使用委托
    //委托方法
    Func<Product, bool> fun = delegate(Product n)
    {
    return n.Price > ;
    };
    var pro3 = Products.OrderByDescending(fun);
    //或者(委托简写)
    var pro4 = Products.OrderByDescending(k=>k.Price>);

最新文章

  1. select初始化添加option,通过标签给出回显值,由于回显值和初始化值option中有一个值重复,去重等问题!
  2. 将excel文件批量转成pdf
  3. MVVM架构~前台后台分离的思想与实践
  4. poj1637 Sightseeing tour
  5. IOS启动顺序
  6. Windows 7下安装MongoDB
  7. C语言的变量的内存分配
  8. C++11 作用域内枚举
  9. 根据hash值找到bt种子的磁力下载链
  10. mybatis的typeHandler
  11. pyspider爬取数据存入redis--2.测试数据库连通性
  12. eventql部署过程
  13. drupal7 hook_validate
  14. 在虚拟机下安装Ubuntu
  15. Oracle查询优化-插入、更新与删除
  16. Web安全之CSRF攻击的防御措施
  17. Sheldon Numbers GYM -- 枚举
  18. [JZOJ5426]摘Galo
  19. php解析二维码
  20. ZOJ18th省赛 Lucky 7

热门文章

  1. mysql 分页查询
  2. DOM对象—选中执行效果
  3. javase--&gt;基础知识(二)
  4. PHP Math 函数
  5. 《Python操作SQLite3数据库》快速上手教程
  6. 3 3Sum closest_Leetcode
  7. Mac下没有权限启动tomcat的解决办法
  8. git 的基本使用
  9. Nginx配置文件nginx.conf中文详解
  10. C#开发中常用方法2------json转DataTable