zoukankan      html  css  js  c++  java
  • C# Linq 笛卡尔积

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace ConsoleApp
    {
        public class Ye
        {
            public string Y { get; set; }
    
            public string E { get; set; }
        }
    
        public class Hao
        {
            public string H { get; set; }
    
            public string A { get; set; }
    
            public string O { get; set; }
        }
    
    
        class Program
        {
            static void Main(string[] args)
            {
                List<Ye> yes = new List<Ye>() {
                    new Ye() { E = "e1", Y = "y1" },
                    new Ye() { E = "e2", Y = "y2" },
                    new Ye() { E = "e3", Y = "y3" },
                };
    
                List<Hao> haos = new List<Hao>()
                {
                    new Hao(){ A="A1", H="H1", O="O1" },
                    new Hao(){ A="A2", H="H2", O="O2" },
                    new Hao(){ A="A3", H="H3", O="O3" }
                };
                //笛卡尔积
                var data = from d in yes
                           from t in haos
                           select new { d, t };
                //笛卡尔积
                var data1 = from d in yes
                           from t in haos
                           select new
                           {
                               d.E,
                               d.Y,
                               t.A,
                               t.H,
                               t.O
                           };
                Console.Read();
    
            }
           
        }
    }
  • 相关阅读:
    Linux统计文件个数
    python string与list互转
    Python中请使用isinstance()判断变量类型
    xpath提取多个标签下的text
    内存盘
    Watchdog
    渗透测试
    GMT与UTC简介
    ASN.1(抽象语法标记)
    Linux nmap
  • 原文地址:https://www.cnblogs.com/haosit/p/10830715.html
Copyright © 2011-2022 走看看