using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication2
{
class A
{
public string type;
public string value;
}
class B
{
public string name;
public string age;
}
class Program
{
static void Main(string[] args)
{
var As = new List<A>{ new A{ type = "1", value = "a" },
new A{ type = "1", value = "b" },
new A{ type = "2", value = "c" },
new A{ type = "2", value = "d" },
new A{ type = "2", value = "e" } };
//按照type分组 算出count 指定 B 为返回类型
linq返回指定类型并添加该类型数据
最新推荐文章于 2023-11-17 19:10:36 发布
这篇博客展示了如何使用LINQ根据输入数据创建指定类型的集合,并演示了尝试直接向LINQ查询结果添加元素时遇到的问题以及解决方法。
摘要由CSDN通过智能技术生成