C# PropertyInfo(官网)
using System;
using System.Reflection; class Module1
{
public static void Main()
{
// This variable holds the amount of indenting that
// should be used when displaying each line of information.
Int32 indent = ;
// Display information about the EXE assembly.
Assembly a = typeof(Module1).Assembly;
Display(indent, "Assembly identity={0}", a.FullName);
Display(indent+, "Codebase={0}", a.CodeBase); // Display the set of assemblies our assemblies reference. Display(indent, "Referenced assemblies:");
foreach (AssemblyName an in a.GetReferencedAssemblies() )
{
Display(indent + , "Name={0}, Version={1}, Culture={2}, PublicKey token={3}", an.Name, an.Version, an.CultureInfo.Name, (BitConverter.ToString (an.GetPublicKeyToken())));
}
Display(indent, ""); // Display information about each assembly loading into this AppDomain.
foreach (Assembly b in AppDomain.CurrentDomain.GetAssemblies())
{
Display(indent, "Assembly: {0}", b); // Display information about each module of this assembly.
foreach ( Module m in b.GetModules(true) )
{
Display(indent+, "Module: {0}", m.Name);
} // Display information about each type exported from this assembly. indent += ;
foreach ( Type t in b.GetExportedTypes() )
{
Display(, "");
Display(indent, "Type: {0}", t); // For each type, show its members & their custom attributes. indent += ;
foreach (MemberInfo mi in t.GetMembers() )
{
Display(indent, "Member: {0}", mi.Name);
DisplayAttributes(indent, mi); // If the member is a method, display information about its parameters. if (mi.MemberType==MemberTypes.Method)
{
foreach ( ParameterInfo pi in ((MethodInfo) mi).GetParameters() )
{
Display(indent+, "Parameter: Type={0}, Name={1}", pi.ParameterType, pi.Name);
}
} // If the member is a property, display information about the property's accessor methods.
if (mi.MemberType==MemberTypes.Property)
{
Display(indent, "PropertyName:{0}", mi.Name);
foreach ( MethodInfo am in ((PropertyInfo) mi).GetAccessors() )
{
Display(indent+, "Accessor method: {0}", am);
}
}
}
indent -= ;
}
indent -= ;
}
} // Displays the custom attributes applied to the specified member.
public static void DisplayAttributes(Int32 indent, MemberInfo mi)
{
// Get the set of custom attributes; if none exist, just return.
object[] attrs = mi.GetCustomAttributes(false);
if (attrs.Length==) {return;} // Display the custom attributes applied to this member.
Display(indent+, "Attributes:");
foreach ( object o in attrs )
{
Display(indent+, "{0}", o.ToString());
}
} // Display a formatted string indented by the specified amount.
public static void Display(Int32 indent, string format, params object[] param) {
Console.Write(new string(' ', indent*));
Console.WriteLine(format, param);
}
}
原文地址:https://docs.microsoft.com/zh-cn/dotnet/api/system.reflection.propertyinfo?redirectedfrom=MSDN&view=netframework-4.7.2
C# PropertyInfo(官网)的更多相关文章
- [干货]Chloe官网及基于NFine的后台源码毫无保留开放
扯淡 经过不少日夜的赶工,Chloe 的官网于上周正式上线.上篇博客中LZ说过要将官网以及后台源码都会开放出来,为了尽快兑现我说过的话,趁周末,我稍微整理了一下项目的源码,就今儿毫无保留的开放给大家, ...
- 千呼万唤始出来,微软Power BI简体中文版官网终于上线了,中文文档也全了。。
前几个月时间,研究微软Power BI技术,由于没有任何文档和资料,只能在英文官网瞎折腾,同时也发布了英文文档的相关文章:系列文章,刚好上周把文章发布完,结果简体中文版上线了.哈哈,心里有苦啊,早知道 ...
- Yeoman 官网教学案例:使用 Yeoman 构建 WebApp
STEP 1:设置开发环境 与yeoman的所有交互都是通过命令行.Mac系统使用terminal.app,Linux系统使用shell,windows系统可以使用cmder/PowerShell/c ...
- 一键生成APP官网
只需要输入苹果下载地址,安卓市场下载地址,或者内测下载地址,就能一键生成APP的官网,方便在网上推广. 好推APP官网 www.hotapp.cn/app
- RavenDB官网文档翻译系列第一
本系列文章主要翻译自RavenDB官方文档,有些地方做了删减,有些内容整合在一起.欢迎有需要的朋友阅读.毕竟还是中文读起来更亲切吗.下面进入正题. 起航 获取RavenDB RavenDB可以通过Nu ...
- FineUI(开源版)v4.2.2发布(8年125个版本,官网示例突破300个)!
开源版是 FineUI 的基石,从 2008 年至今已经持续发布了 120 多个版本,拥有会员 15,000 多位,捐赠会员达到 1,200 多位. FineUI(开源版)v4.2.2 是 8 年 ...
- React.js 官网入门教程 分离文件 操作无法正常显示HelloWord
对着React官网的教程练习操作,在做到分离文件练习时,按照官网步骤来却怎么也无法正常显示HelloWord. 经测试,html文件中内容改为: <!DOCTYPE html><ht ...
- 学记:spring boot使用官网推荐以外的其他数据源druid
虽然spring boot提供了4种数据源的配置,但是如果要使用其他的数据源怎么办?例如,有人就是喜欢druid可以监控的强大功能,有些人项目的需要使用c3p0,那么,我们就没办法了吗?我们就要编程式 ...
- maven向本地仓库导入jar包(处理官网没有的jar包)
对于官网没有的jar包,maven向本地仓库导入jar包用如下命令 mvn install:install-file -DgroupId=包名 -DartifactId=项目名 -Dversion=版 ...
- Unity 官网教程 -- Multiplayer Networking
教程网址:https://unity3d.com/cn/learn/tutorials/topics/multiplayer-networking/introduction-simple-multip ...
随机推荐
- python05-09
一.lambda表达式 def f1(): return 123 f2 = lambda : 123 def f3 = (a1,a2): return a1+a2 f4 = lambda a1,a2 ...
- rocketmq消费队列代码
DefaultMQPushConsumer consumer = new DefaultMQPushConsumer(Constant.operationLogGroup); try { consum ...
- hdu2222--Keywords Search+AC自己主动机模板
题目链接:pid=2222">点击进入 KMP对模式串进行处理.然后就能够方便的推断模式串是否在目标串中出现了:这显示适合一个模式串多个目标串的情况.可是假设模式串有多个,这时假设还用 ...
- .NET的委托和匿名函数应用一例
闲话休提,大家都是成年人,直接上代码.有代码有J8: delegate string dlgGetTotal(); void TongJi() { dlgGetTotal getTotalInt = ...
- 2016/5/6 thinkphp ①框架 ② 框架项目部署 ③MVC模式 ④控制器访问及路由解析 ⑤开发和生产模式 ⑥控制器和对应方法创建 ⑦视图模板文件创建 ⑧url地址大小写设置 ⑨空操作空控制器 ⑩项目分组
真实项目开发步骤: 多人同时开发项目,协作开发项目.分工合理.效率有提高(代码风格不一样.分工不好) 测试阶段 上线运行 对项目进行维护.修改.升级(单个人维护项目,十分困难,代码风格不一样) 项目稳 ...
- cygwin安装sshd服务(win7)Error installing a service: OpenSCManager: Win32 error 5:
Error installing a service: OpenSCManager: Win32 error 5: 出现这个问题的解决办法:win7系统管理员运行Cygwin软件 ...
- SetLocalTime API函数设置本地时间(DateTimeToSystemTime函数,把TDateTime转换成TSystemTime)
procedure setLocalDateTime(Value: TDateTime);var lSystemDateTime: TSystemTime;begin DateTimeToSyst ...
- Eclipse添加Qt插件
此文件仅为步骤操作作一个记录,以便以后方便查阅. 1.操作大体参考这个网站:http://blog.csdn.net/defonds/article/details/5013412 2.我的运行环境: ...
- Mac Launchpad图标调整
Launchpad图标大小怎么调整?,很多人觉得默认Launchpad的应用程序图标很大,空间比较拥挤,看起来一点也不精致,那么我们怎样才能调整Launchpad的图标大小呢?其实可以通过调整Laun ...
- YTU 2572: 猜灯谜
2572: 猜灯谜 时间限制: 1 Sec 内存限制: 128 MB 提交: 154 解决: 91 题目描述 A 村的元宵节灯会上有一迷题: 请猜谜 * 请猜谜 = 请边赏灯边猜 小明想,一定是每 ...