栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > .Net

.net Reflector 反编译源码笔记

.Net 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

.net Reflector 反编译源码笔记

使用.net Refector 反编译C#,的确是一个很好的工具,不过随着研究的深入发现,其中还有有一些不尽人意,让初学者摸不着头脑的情况。

源码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

using System.IO;

namespace ConsoleApplication1
{

    class Student
    {
        public int ID { get; set; }
        public string Name { get; set; }
    }
    class Program
    {

static void Main(string[] args)
    {
        // Source 
        var student = new Student { ID = 1, Name = "jello" };

        // Dynamic Assign
        dynamic d = student;
        Console.WriteLine(d.Name);
		
        Console.ReadKey();
    }

    }
}

反编译后的效果
internal class Student
{
    // Properties
    public int ID { get; set; }

    public string Name { get; set; }
}

 
internal class Program
{
    // Methods
    private static void Main(string[] args)
    {
        CSharpArgumentInfo[] infoArray;
        Student student2 = new Student {
            ID = 1,
            Name = "jello"
        };
        object obj2 = student2;
        if (
o__SiteContainer1.<>p__Site2 == null) { infoArray = new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.IsStaticType | CSharpArgumentInfoFlags.UseCompileTimeType, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) };
o__SiteContainer1.<>p__Site2 = CallSite>.Create(Binder.InvokeMember(CSharpBinderFlags.ResultDiscarded, "WriteLine", null, typeof(Program), infoArray)); } if (
o__SiteContainer1.<>p__Site3 == null) { infoArray = new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) };
o__SiteContainer1.<>p__Site3 = CallSite>.Create(Binder.GetMember(CSharpBinderFlags.None, "Name", typeof(Program), infoArray)); }
o__SiteContainer1.<>p__Site2.Target(
o__SiteContainer1.<>p__Site2, typeof(Console),
o__SiteContainer1.<>p__Site3.Target(
o__SiteContainer1.<>p__Site3, obj2)); Console.ReadKey(); } }

Student结构体很清晰,不过一个dynamic 关键字就很复杂啦!

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/955660.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号