zoukankan      html  css  js  c++  java
  • IEnumerable中运用yield

     protected void Page_Load(object sender, EventArgs e)
    {
    var temp
    = Getreturn();
    var temp1
    = temp.ToList();//返回List<string> 5条数据
    temp.All(o =>//调用 Getreturn()中的for循环数据
    {
    Response.Write(o);
    return true;
    });
    Getreturns().All(o
    =>
    {
    //o的类型为 IEnumerable<string>
    return true;
    });
    //Response.Write(Getreturn());
    }
    public IEnumerable<string> Getreturn()
    {
    for (int i = 0; i < 5; i++)
    {
    yield return "wode";
    }
    }
    public IEnumerable<IEnumerable<string>> Getreturns()
    {
    List
    <string> list = new List<string>();
    list.Add(
    "wode");
    list.Add(
    "wode1");
    for (int i = 0; i < 5; i++)
    {
    yield return list;
    }
    }
    }
  • 相关阅读:
    Linux基础命令---swapon
    Linux基础命令---fsck
    Linux基础命令---e2fsck
    Combination Sum
    Pow(x, n)
    Permutations
    Permutation Sequence
    Rotate List
    Unique Paths II
    Unique Paths
  • 原文地址:https://www.cnblogs.com/shikyoh/p/2113875.html
Copyright © 2011-2022 走看看