第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

此代碼中反射的輸出類(lèi)型是什么

此代碼中反射的輸出類(lèi)型是什么

我有以下方法:public static class ReflectionHelper{    public static List<?> FindType<T>()    {        var A =            from Assemblies in AppDomain.CurrentDomain.GetAssemblies().AsParallel()            from Types in Assemblies.GetTypes()            let Attributes = Types.GetCustomAttributes(typeof(T), true)            where Attributes?.Length > 0            select new { Type = Types };        var L = A.ToList();        return L;    }}列表的類(lèi)型是什么?如果我做:foreach (var l in L) { ... }它可以找到并且我可以檢查類(lèi)型,但是我正在使用的開(kāi)發(fā)環(huán)境 (Rider) 不會(huì)提供類(lèi)型
查看完整描述

1 回答

?
喵喔喔

TA貢獻(xiàn)1735條經(jīng)驗(yàn) 獲得超5個(gè)贊

它是一個(gè)具有單一屬性的匿名對(duì)象


IEnumerable<Type> Types;

所以,使用A.ToList()給你一個(gè)匿名對(duì)象的列表,你不能返回。


我認(rèn)為select new { Type = Types };你想使用而不是使用select Types;


所以:


public static List<Type> FindType<T>()

{

    var types =

        from ssembly in AppDomain.CurrentDomain.GetAssemblies().AsParallel()

        from type in ssembly.GetTypes()

        let attributes = type.GetCustomAttributes(typeof(T), true)

        where attributes?.Length > 0

        select type;


    return types.ToList();

}


查看完整回答
反對(duì) 回復(fù) 2022-12-24
  • 1 回答
  • 0 關(guān)注
  • 100 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)