zoukankan      html  css  js  c++  java
  • Linq联接

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    namespace Linq联接
    {
        class Program
        {
            public class Student 
            {
                public int stID;
                public string LastName;
            }
            public class CourseStudent
            {
                public string CourseName;
                public int stID;
            }
            static Student[] students = new Student[] { 
                        new Student { stID = 1, LastName = "Carson" } ,
                        new Student { stID = 2, LastName = "Jack" }, 
                        new Student { stID = 3, LastName = "Tom" } 
                         };
            static CourseStudent[] courseStudents = new CourseStudent[]{
            new CourseStudent{CourseName="asd",stID=1},
            new CourseStudent{CourseName="asd",stID=2},
            new CourseStudent{CourseName="sfh",stID=1},
            new CourseStudent{CourseName="dgfsd",stID=2},
            new CourseStudent{CourseName="dgfsd",stID=3},
            };
            static void Main(string[] args)
            {
                var query = from s in students          //s和c是迭代器
                            join c in courseStudents
                            on s.stID equals c.stID
                            where c.CourseName == "asd"
                            select s.LastName;
                foreach (var q in query)
                    Console.WriteLine("Student Taking asd :{0}",q);
                Console.ReadKey();
            }
        }
    }
  • 相关阅读:
    海量数据处理:十道面试题与十个海量数据处理方法总结
    C++中的static及内存分配
    面试时如何向面试官提问
    面试题3:斐波那契数列与爬楼梯
    面试题1:二进制中1的个数
    面试题:单链表的几种处理
    js网页下载csv格式的表格
    解决背景图文字盖住html里面的dom元素
    使用element-ui的常见问题
    Promise-async-await处理函数
  • 原文地址:https://www.cnblogs.com/sulong/p/4808051.html
Copyright © 2011-2022 走看看