[WinForm] 获取 Resources 资源文件里里指定类型的数据列表

来源:互联网 发布:一般网络女主播的收入 编辑:程序博客网 时间:2024/05/23 20:26

本渣突然要用到,但网上没有好的答案,于是就自己写了。

尽管说不解释一来就上代码基本都是招摇过市,但我词穷说不出来啊哭


//using System.Reflection;//using 项目名.Properties;        List<T> GetResources<T>()        {            var resources = typeof(Resources).GetProperties(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Instance)                .Select(property => property.GetValue(property.Name, null))                .Where(obj => obj is T)                .Select(obj => (T)obj)                .ToList<T>();            return resources;        }


本渣原创,转载请注明,如有雷同,特么的就是巧合敲打


请随意转载,就说是你写的。。。
0 0