zoukankan      html  css  js  c++  java
  • C# List分组(IGroup)

        static void Main(string[] args)
            {
                List<BankAccountFile> fileList = new List<BankAccountFile>
                {
                     new BankAccountFile{   BankCode= "ICBC",
            BankAccountNum= "1001222309024",
            Period="202105",
            BankAcctPath="D:\SEPC.FSSC.ReceiptFile\ICBC\DZD\month\1001222309024_202105_page1_001.html"
                     },
                      new BankAccountFile{   BankCode= "ICBC",
            BankAccountNum= "1001222309024",
            Period="202105",
            BankAcctPath="D:\SEPC.FSSC.ReceiptFile\ICBC\DZD\month\1001222309024_202105_page1_002.html"
                     },
                       new BankAccountFile{   BankCode= "ICBC",
            BankAccountNum= "1001222309024",
            Period="202105",
            BankAcctPath="D:\SEPC.FSSC.ReceiptFile\ICBC\DZD\month\1001222309024_202105_page1_003.html"
                     },
                        new BankAccountFile{   BankCode= "ICBC",
            BankAccountNum= "1001222309024",
            Period="202105",
            BankAcctPath="D:\SEPC.FSSC.ReceiptFile\ICBC\DZD\month\1001222309024_202105_page1_004.html"
                     },
                           new BankAccountFile{   BankCode= "ICBC",
            BankAccountNum= "1001222309024",
            Period="202106",
            BankAcctPath="D:\SEPC.FSSC.ReceiptFile\ICBC\DZD\month\1001222309024_202106_page1_001.html"
                     },
                                     new BankAccountFile{   BankCode= "ICBC",
            BankAccountNum= "1001222309024",
            Period="202106",
            BankAcctPath="D:\SEPC.FSSC.ReceiptFile\ICBC\DZD\month\1001222309024_202106_page1_002.html"
                     },
                                      new BankAccountFile{   BankCode= "ICBC",
            BankAccountNum= "1001222309024",
            Period="202106",
            BankAcctPath="D:\SEPC.FSSC.ReceiptFile\ICBC\DZD\month\1001222309024_202106_page1_002.html"
                     }
                 };
    
                List<BankAccountFile> newList1 = new List<BankAccountFile>(); 
                foreach (IGrouping<string, BankAccountFile> group in fileList.GroupBy(c => c.Period))
                {
    
                    BankAccountFile model = new BankAccountFile();
                    model.Period = group.Key; 
                    foreach (BankAccountFile stu in group.OrderBy(a => a.Period))
                    {
                        Console.Write(stu.BankAcctPath + ";");
                        model.BankCode = stu.BankCode;
                        model.BankAccountNum = stu.BankAccountNum;
                        model.BankAcctPath = stu.BankAcctPath; 
                    }
                    model.FileList = group.OrderBy(a => a.Period).ToList();
                    newList1.Add(model); 
                } 
            }
    
            public class BankAccountFile
            {
                /// <summary>
                /// 银行简码
                /// </summary>
                public string BankCode { get; set; }
                /// <summary>
                /// 银行账号
                /// </summary>
                public string BankAccountNum { get; set; }
                /// <summary>
                /// 期间
                /// </summary>
                public string Period { get; set; }
                /// <summary>
                /// 下载路径
                /// </summary>
                public string BankAcctPath { get; set; }
    
                /// <summary>
                /// 银行账号名称
                /// </summary>
                public string BankAccountName { get; set; }
    
                /// <summary>
                /// 组装多条数据的List
                /// </summary>
                public List<BankAccountFile> FileList { get; set; }
            }
    

      

    生命中最值得欣慰的,莫过于一觉醒来,你还在身旁
  • 相关阅读:
    Linux标准C头文件和内核头文件的理解
    linux GCC编译C程序的问题
    C#类型反射、晚期绑定、特性编程的使用背景与分析
    linux下C#开发mongoDB
    C中“指针和数组”引发的探索一
    C#学习记录
    linux下Apache+PHP+mysql+phpMyAdmin源码包安装配置
    基于mongoDB和C#分布式海量文件存储实验
    C中指针和数组引发的探索二
    算法研究学习一(用C和C#实现)
  • 原文地址:https://www.cnblogs.com/chaonuanxi/p/15379442.html
Copyright © 2011-2022 走看看