Is there any mini C# console application available to pursue Reflection ?
Playing around Reflection
Asked
Viewd249
0
5 个答案
1
Nice . Six months back i went through a link that is a game based on reflection ,very useful to learn how the technique works.but the link is broken.
– August 10, 2009 08:49
1
IronPython 用于播放.NET
个对象。不是C#
,而是对所有.NET
对象的直接反映。
>>> import clr
>>> import System
>>> ip=System.Net.IPAddress(System.Array[System.Byte]([10,0,0,1]))
>>> ip
<System.Net.IPAddress object at 0x0000000000000034 [10.0.0.1]>
>>> dir(ip)
['Address', 'AddressFamily', 'Any', 'Broadcast', 'Equals', 'GetAddressBytes', 'G
etHashCode', 'GetType', 'HostToNetworkOrder', 'IPv6Any', 'IPv6Loopback', 'IPv6No
ne', 'IsIPv6LinkLocal', 'IsIPv6Multicast', 'IsIPv6SiteLocal', 'IsLoopback', 'Loo
pback', 'MemberwiseClone', 'NetworkToHostOrder', 'None', 'Parse', 'ReferenceEqua
ls', 'ScopeId', 'ToString', 'TryParse', '__class__', '__delattr__', '__doc__', '
__eq__', '__getattribute__', '__hash__', '__init__', '__ne__', '__new__', '__red
uce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__']
>>> ip.Address
16777226L
>>>
2
您是否在Visual Studio中尝试过即时窗口? / p>
我建议您尝试使用 System.Reflection命名空间中的类型。试一下Assembly,Field / MethodInfo,Activator和Type类。
要了解程序集和IL,请参阅 System.Reflection.Emit命名空间。一个很好的例子是 TypeBuilder类。
0
我同意 Reflector 实用程序对于Explorer .NET程序集是一个非常不错的实用程序。
如果您想构建自己的反射应用程序以了解元数据的结构,我建议您阅读专家.NET 2.0 IL汇编程序。它很好地总结了如何 今天,元数据是在程序集中构造的。
.NET框架已经向开发人员公开了一些反射工具,如用户“ weiqure”所述,我建议您对System.Reflection
名称空间进行采样,以开始使用反射。
@rengaseshan: No offence but reflector is already written, and it’s expert territory to write something like it.
– Mitch WheatAugust 10, 2009 08:14For Example I am pointing “Reflector”. Actually i need to dynamically play around the assembly. so i wish imbibe deep programming knowledge in reflection. Clear ?
– user146584August 10, 2009 08:18There is a quite good list of reflection samples here: http://www.google.com/search?q=c%23+reflection+tutorial
– Dirk VollmarAugust 10, 2009 08:17I mean i wish to acquire in depth knowledge of reflection in C#. I wish to develop an application like “Reflector”.
– user146584August 10, 2009 08:11What do you mean, pursue? Reflection can be used in any type of application.
– Cecil Has a NameAugust 10, 2009 08:03