1、打开microsoft  visual  studio  2008  /  visual  studio  tools /  visual  studio  2008 命令提示  ,并输入ildasm 。如下图所示:

2、按enter键,打开IL DASM 窗口,如下图所示:

3、单击 文件 / 打开,打开编译好的.exe文件,即可查看该代码的IL代码

例如:通过visual  studio  2008 命令提示 查看如下源程序的IL代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BubbleSort
{
   class BubbleSort1
    {//升序排序,每一趟都将最大的一个数放在最后
        public static void BubbleSort(int[] items)
        {
            int i, j, temp;
            if (items == null)
                return;
            for (i = items.Length - 1; i >= 0; i++)
                for (j=1;j<=i;j++)
                    if (items[j - 1] > items[j])
                    {
                        temp = items[j - 1];
                        items[j - 1] = items[j];
                        items[j] = temp;
                    }
         }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BubbleSort
{
    class BubbleSort2
    {
        public enum SortType
        {
            Ascending,
            Descending
        }
        public static void BubbleSort(int[] items, SortType sortOrder)
        {
            int i, j, temp;
            if (items == null)
                return;
            for (i = items.Length - 1; i >= 0; i++)
            {
                for (j = 1; j <= i; j++)
                {
                    switch (sortOrder)
                    {
                        case SortType.Ascending:
                            if (items[j - 1] > items[j])
                            {
                                temp = items[j - 1];
                                items[j - 1] = items[j];
                                items[j] = temp;

}
                            break;
                        case SortType.Descending:
                            if (items[j - 1] < items[j])
                            {
                                temp = items[j - 1];
                                items[j - 1] = items[j];
                                items[j] = temp;
                            }
                            break;
                    }

}
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BubbleSort
{
    public delegate bool ComparisonHandler (int first,int second);//委托类型的声明
    class BubbleSort3
    {
        public static bool GreaterThan(int first, int second)
        {//升序排序
            return first > second;
        }
        public static bool LessThan(int first, int second)
        {//降序排序
            return first < second;
        }
        public static bool AlphabeticalGreaterThan(int first, int second)
        {//按照字母表排序。a.CompareTo(b):若a>b 返回值小于0, a<b返回值大于0,
            //a=b返回值等于0
            int comparison;
            comparison = (first.ToString().CompareTo(second.ToString()));
            return comparison > 0;
        }
        public static void BubbleSort(int[] items, ComparisonHandler comparisonMethod)
        {
            int i, j, temp;
            if (items == null)
                return;
            if (comparisonMethod == null)
                throw new ArgumentNullException("comparisonMethod");
            for (i = items.Length - 1; i >= 0; i--)
            {
                for(j=1;j<=i;j++)
                    if (comparisonMethod(items[j - 1], items[j]))
                    {
                        temp = items[j - 1];
                        items[j - 1] = items[j];
                        items[j] = temp;
                    }
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BubbleSort;

namespace BubbleSort
{
    class Program
    {
        static void Main(string[] args)
        {
            int intcount;
            Console.WriteLine("请输入待排序的整数序列的个数:");
            intcount = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("请输入待排序的整数序列:");
            int[] items = new int[intcount];
            for (int i = 0; i < intcount; i++)
            {
                items[i]=Convert .ToInt32 (  Console.ReadLine());
               
             }

ComparisonHandler comparisonMethod = BubbleSort3.GreaterThan;
            BubbleSort3.BubbleSort(items, comparisonMethod);
            Console.WriteLine("调用类BubbleSort3中的排序方法排序后的整数序列为:");
            for(int i=0;i<intcount;i++)
            {
                Console.Write(items[i]);
                Console.Write("   ");

}

}
    }
}

以上程序的IL代码:

C# 如何查看源程序的IL代码的更多相关文章

  1. C#程序集系列02,使用记事本查看可执行程序集的IL代码

    继续上一篇"C#程序集系列01,用记事本编写C#,IL代码,用DOS命令编译程序集,运行程序",在F盘的as文件夹中已经有了若干程序集.本篇体验使用记事本查看可执行程序集的IL代码 ...

  2. CLR基础,CLR运行过程,使用dos命令创建、编译、运行C#文件,查看IL代码

    CLR是Common Language Runtime的缩写,是.NET程序集或可执行程序运行的一个虚拟环境.CLR用于管理托管代码,但是它本身是由非托管代码编写的,并不是一个包含了托管代码的程序集, ...

  3. 读懂IL代码就这么简单 (一)

    一前言 感谢 @冰麟轻武 指出文章的错误之处,现已更正 对于IL代码没了解之前总感觉很神奇,初一看完全不知所云,只听高手们说,了解IL代码你能更加清楚的知道你的代码是如何运行相互调用的,此言一出不明觉 ...

  4. 读懂IL代码就这么简单

    原文地址:http://www.cnblogs.com/zery/p/3366175.html 一前言 感谢 @冰麟轻武 指出文章的错误之处,现已更正 对于IL代码没了解之前总感觉很神奇,初一看完全不 ...

  5. 读懂IL代码(一)

    以前刚开始学C#的时候,总有高手跟我说,去了解一下IL代码吧,看懂了你能更加清楚的知道你写出来的代码是如何运行互相调用的,可是那时候没去看,后来补的,其实感觉也不晚.刚开始看IL代码的时候,感觉非常吃 ...

  6. 详解.NET IL代码(一)

    本文主要介绍IL代码,内容大部分来自网上,进行整理合并的. 一.IL简介 为什么要了解IL代码? 如果想学好.NET,IL是必须的基础,IL代码是.NET运行的基础,当我们对运行结果有异议的时候,可以 ...

  7. 如何解读IL代码

    如何解读IL代码 关于IL代码,我有将从三个方面去揭开它神秘的面纱.IL代码是什么?我们为什么要去读懂IL代码?我们如何去读懂IL代码?这三个问题的解答,将是我解读IL代码的整体思路. IL代码是什么 ...

  8. 【转载】读懂IL代码就这么简单 (一)

    一前言 感谢 @冰麟轻武 指出文章的错误之处,现已更正 对于IL代码没了解之前总感觉很神奇,初一看完全不知所云,只听高手们说,了解IL代码你能更加清楚的知道你的代码是如何运行相互调用的,此言一出不明觉 ...

  9. 详解.NET IL代码

    一.前言 IL是什么? Intermediate Language (IL)微软中间语言 C#代码编译过程? C#源代码通过LC转为IL代码,IL主要包含一些元数据和中间语言指令: JIT编译器把IL ...

随机推荐

  1. 新版TeamTalk部署教程(蓝狐)

    http://www.bluefoxah.org/teamtalk/new_tt_deploy.html

  2. IOS回调机制——代理,通知中心以及Block

    Xcode5.0正式版 IOS7和Xcode5正式版在昨天正式可以下载.IOS7不多说了,交互设计,界面风格,操作的简化程度都属于比较领先的水平. 这里来说说Xcode5正式版,和以前的Xcode5测 ...

  3. [Android开发常见问题-18] Connection to https://dl-ssl.google.com refused

    在使用Android SDK Manager的时候,有时候会遇到上述问题,其实原因很简单,属于本地配置的问题. 解决方法: 1.以文本文件的方式打开“C:\Windows\System32\drive ...

  4. hdu3410-Passing the Message(RMQ,感觉我写的有点多此一举。。。其实可以用单调栈)

    What a sunny day! Let’s go picnic and have barbecue! Today, all kids in “Sun Flower” kindergarten ar ...

  5. 04747_Java语言程序设计(一)_第4章_数组和字符串

    面试题 字符串连接 public class Aserver { public static void main(String args[]) { // 字符串数据和其他数据+,结果是字符串类型 // ...

  6. PHP foreach()跳出本次或当前循环与终止循环方法

    PHPforeach()跳出本次或当前循环与终止循环方法 PHP中用foreach()循环中,想要在循环的时候,当满足某个条件时,想 $arr = array('a','b','c','d','e') ...

  7. jQuery 动画之 添加商品到购物车

    前台页面 <link href="MyCar.css" rel="stylesheet" /> <script src="../jq ...

  8. Unity SendMessage方法

    我们今天研究下SendMessage方法, 如果我们需要执行某一个组件的方法时候可以使用SendMessage gameObject.SendMessage("A"); 即可通知当 ...

  9. Hibernate框架大配置关联小配置

    1 <?xml version='1.0' encoding='utf-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-// ...

  10. Spring Tool Suit 在Eclipse上的安装

    登录http://spring.io/tools/sts/all 下载所需的Spring Tool Suit安装包 我用的是springsource-tool-suite-3.6.1.RELEASE- ...