如题 比如说我有一个
public void output()
{
Console.writeline("hello");}public void method()
{
//在这里我想把output这个方法以字符串的形式表示显示出来,怎么做呀?
}大家帮帮我
public void output()
{
Console.writeline("hello");}public void method()
{
//在这里我想把output这个方法以字符串的形式表示显示出来,怎么做呀?
}大家帮帮我
解决方案 »
- 使用WeifenLuo.WinFormsUI.Docking控件如何让打开的窗体居中
- Xilmerge:界面版的ILMerge,将引用的DLL和exe文件打成一个exe文件,带源码[图]
- 关于下拉框的问题!急急急急急!!!!
- C#如何在视频窗口中自定义画出距形,然后把距形的大小作为视频窗口的大小?
- 如何改变ListView中某一个单元格的背景色
- 40分,在win2003上如何设置才能支持shtml,请详细说明,立即给分!
- 使用DataReader读取DataSet
- 在调用treeview中的AfterLabelEdit事件修改数据库时为什么会一直执行里面的内容多次?
- PPC开发中button.text不能分行显示问题.
- 视频上传和转码
- C#使用水晶报表好像只能显示已定的字段,当每次查询结果的字段都不相同,且字段数也不等时就无能为力,这一般如何解决?
- Timer组件
{ MethodInfo[] mInfos = typeof(A).GetMethods();
foreach (MethodInfo method in mInfos)
Console.WriteLine("method:{0}",method.Name);
}类A public class A
{
public void f() { int i = 0; }
}
{
Console.writeline("hello");} ” 这样的字符串
然后使用
using Reflector;
using Reflector.CodeModel;
就可以是其提供的反编译功能,实现你的东西具体可以参考
http://www.cnblogs.com/worksguo/articles/988180.html
http://www.cnblogs.com/smalldust/archive/2006/08/30/490742.html
我用Reflector.exe做了一个简单的例子,基本上可以把当前的反编译出来,不过在界面显示上没优化,看起来有点乱
public partial class Form1 : Form
{
IServiceProvider serviceProvider;
ILanguageManager languageManager;
public Form1()
{
InitializeComponent();
} private void Form1_Load(object sender, EventArgs e)
{
serviceProvider = new ApplicationManager(null);
languageManager = (ILanguageManager)serviceProvider.GetService(typeof(ILanguageManager));
IAssemblyManager assemblyManager = (IAssemblyManager)serviceProvider.GetService(typeof(IAssemblyManager));
var a = this.GetType();
IAssembly assembly = assemblyManager.LoadFile(this.GetType().Module.FullyQualifiedName); StringBuilder output = new StringBuilder();
output.AppendLine("装配件: " + assembly.ToString()); foreach (IModule module in assembly.Modules)
{
output.AppendLine(("模块: " + module.Name)); foreach (ITypeDeclaration typeDeclaration in module.Types)
{
output.AppendLine(("类型: " + typeDeclaration.Namespace + "." + typeDeclaration.Name)); foreach (IMethodDeclaration methodDeclaration in typeDeclaration.Methods)
{
output.AppendLine(("方法: " + methodDeclaration)); IMethodBody methodBody = methodDeclaration.Body as IMethodBody;
if (methodBody != null)
{
foreach (IInstruction instruction in methodBody.Instructions)
{
output.Append("L" + instruction.Offset.ToString("X4", CultureInfo.InvariantCulture));
output.Append(": ");
//output.Append(InstructionTable.GetInstructionName(instruction.Code));
output.Append(instruction.Code);
if (instruction.Value != null)
{
output.Append(" "); if (instruction.Value is string)
{
output.Append("\"");
} output.Append(instruction.Value.ToString()); if (instruction.Value is string)
{
output.Append("\"");
}
} output.AppendLine();
}
}
}
}
} this.richTextBox1.Clear();
this.richTextBox1.Text = output.ToString();
}
}}