[100分,CSDN8年老用户求助!]关于反射,泛型,Linq相关问题

yuandonghuia yuandonghuia 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
各位大神好久不见,这是玩CSDN的第八个年头了,白驹过隙啊!最近几年来干的事越来越杂,代码越写越少了.
但是最近又在设计一个框架遇到反射的一些问题.请教各位大神了.
PS.在我玩论坛的那几年,caozhy是比较常见的大神了,其他的都记不清名字了.
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
public class teatca
{
public string A { get; set; }
public string B { get; set; }
}

public class testc
{
public List<teatca> As { get; set; }
}
class Program
{
static void Main(string[] args)
{
testc cc = new testc();
var bb = cc.As;
var bbwhere = bb.Where(x => x.A == "aaa");
//第一个集合通过查询资料已经解决了,第二个实在是在网上查询不到解决方案才敢叨扰各位大神!
var bb1 = cc.GetType().GetProperty("As").GetValue(cc);
//我知道下面的写法不对,我就是想用反射的方法来实现linq语句,实现where 求各位大神!!!
//我就想让bbwhere1的值和bbwhere一样就可以
var bbwhere1 = bb1.GetType().GetGenericArguments().Where(x => x.GetProperty("A").GetValue(x).ToString() == "aaa");
Console.ReadLine();
}
}
}
...全文
评论 15
收藏 已收藏
分享
返回顶部
yuandonghuia
C# 111,128 成员 642,536 内容