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 ...
随机推荐
- 使用WIN32汇编语言实现一个基本windows窗体的过程分析
一个常规的windows窗体一般都是一些一样的构造.你假设想要更改一些个性化的设置,你能够在这个一般的模板伤添砖加瓦.构造自己比較喜欢的类型.下边就分析一下一般的windows窗体的一般模板. 一. ...
- bug集合及其解决方法
点击查看原文 1. java.lang.IllegalStateException: Expected a string but was BEGIN_ARRAY at line 1 column 27 ...
- httpclient发送get请求
/** * 获取httpclient的请求url地址 */ public static String getUrl(){ String url = "http://"+map.ge ...
- 【剑指Offer面试题】 九度OJ1517:链表中倒数第k个结点
鲁棒性是指程序可以推断输入是否符合规范要求,并对不和要求的输入予以 合理的处理. 题目链接地址: http://ac.jobdu.com/problem.php?pid=1517 题目1517:链表中 ...
- eclipse maven 插件的安装和配置
maven3 安装: 安装 Maven 之前要求先确定你的 JDK 已经安装配置完毕.Maven是 Apache 下的一个项目.眼下最新版本号是 3.0.4.我用的也是这个. 首先去官网下载 Mave ...
- HDU 3469 Catching the Thief (博弈 + DP递推)
Catching the Thief Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
- 我的kindle书单
刚刚入手kindle,希望能够持续阅读,不断进步. 列下书单,记录我的阅读足迹,更希望园友若有好书多多推荐,互相交流. # keep updating ... 我的kindle书单 book name ...
- 跨域,Content-Type组件
1,跨域:是浏览器的同源策略 阻止ajax请求不组织src请求 2,一个源的定义:如果两个页面的协议,端口(如果由指定)和域名都相同,则两个页面具有相同的源 下面给出相对http://a.xyz.co ...
- myeclipse提示:Syntax error on tokens, delete these tokens怎么解决
有中文字符或者符号,包括空格. 上次遇到一个问题,检查了一遍语法没错误, 后来发现是拷贝代码的时候有一部分中文空格没删除,就出现这个问题了. 一个个删除就OK了.
- Trie(前缀树)和ternary trie和binary search tree
1 什么是trie trie是一棵多叉树,假如存放的是由26个字母(不区分大小写)构成的字符串的话,那么就是一棵26叉树. trie树是一棵前缀树,因为每个结点只保存字符串中的一个字符,整个字符串保存 ...