LINQ查询语句案例学生表、成绩表、课程表

这段代码展示了如何使用LINQ进行查询操作,包括查询学生的所有信息、姓名、姓名长度、年龄,以及按不同条件排序和分组。还演示了对学生成绩的复杂查询,如分数大于80的分组展示和不同数组间的联接操作。
摘要由CSDN通过智能技术生成

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LINQ3
{
    class Student
    {
        /// <summary>
        ///学生姓名的字段和属性
        /// </summary>
        private string _Name;
        public string Name
        {
            get { return this._Name; }
        }
        private string _Xingbie;
        /// <summary>
        /// 学生性别的字段和属性
        /// </summary>
        public string Xingbie
        {
            get { return this._Xingbie; }
        }
        /// <summary>
        /// 学生年龄的字段和属性
        /// </summary>
        private uint _Age;
        public uint Age
        {
            get { return this._Age; }
        }
        /// <summary>
        /// 学生成绩的字段和属性
        /// </summary>
        private List<LessonScore> _Scores;
        public List<LessonScore> Scores
        {
            get { return this._Scores; }
        }
        /// <summary>
        /// 构造函数,传入学生姓名,性别,年龄,成绩
        /// </summary>
        public Student(string name, string xb, uint age, List<LessonScore> scrs)
        {
            this._Name = name;
            this._Xingbie = xb;
            this._Age = age;
            this._Scores = scrs;
        }
        public Student(string name, string xb, uint age)
        {
            this._Name = name;
            this._Xingbie = xb;
            this._Age = age;
            this._Scores = null;
        }
        public override string ToString()
        {
            string str;
            str = string.Format("{0}--{1}--{2}", this._Name, this._Age, this._Xingbie);
            return str;
        }

    }

    class LessonScore
    {
        /// <summary>
        /// 课程成绩的字段和属性
        /// </summary>
        private float _Score;
        public float Score
        {
            get { return this._Score; }
        }
        /// <summary>
        /// 课程名称的字段和属性
        /// </summary>
        private string _Lessson;
        public string Lesson
        {
            get { return this._Lessson; }
        }
        /// <summary>
        /// 构造函数
        /// </summary>
        public LessonScore(string les, float scr)
        {
            this._Lessson = les;
            this._Score = scr;
        }

        public override string ToString()
        {
            string str;
            str = string.Format("{0}----{1}分", this._Lessson, this._Score);
   

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值