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. Prime Palindrome Golf

    Prime Palindrome Golf Do you know how to play Prime Palindrome Golf? You are given a number and your ...

  2. php curl 中的gzip压缩性能测试

    前因: 请求接口次数很多,每日两亿多次,主要是有些接口返回数据量很大高达110KB(为了减少请求次数,将多个接口合并成一个导致的).后端接口的nginx已经开启gzip,所以做个测试,看看是否在请求时 ...

  3. 深入浅出Node.js (3) - 异步I/O

    3.1 为什么要异步I/O 3.1.1 用户体验 3.1.2 资源分配 3.2 异步I/O实现现状 3.2.1 异步I/O与非阻塞I/O 3.2.2 理想的非阻塞异步I/O 3.2.3 现实的异步I/ ...

  4. Inorder Successor in BST 解答

    Question Given a binary search tree and a node in it, find the in-order successor of that node in th ...

  5. [置顶] Objective-C ,ios,iphone开发基础:在UITextField输入完以后,隐藏键盘,

    在x-code Version 4.3.2 (4E2002)下编译: 在 Controller. m 文件下添加如下实例方法即可: - (void)viewDidUnload { [super vie ...

  6. POJ 3046 Ant Counting DP

    大致题意:给你a个数字,这些数字范围是1到t,每种数字最多100个,求问你这些a个数字进行组合(不包含重复),长度为s到b的集合一共有多少个. 思路:d[i][j]——前i种数字组成长度为j的集合有多 ...

  7. pyqt MainWindow记录内容

    class Texts(QtGui.QMainWindow,Ui_MainWindow): def __init__(self,parne=None): super(Texts,self).__ini ...

  8. Windows Live Writer 代码插件改造

    源码和插件都在后面,如果不想看我神神叨叨的可以直接到文章后面下载 一 .找插件 在使用Windows Live Writer 经常要用到插入代码的功能,根据博客园中教程,分别使用了: WindowsL ...

  9. linux在文件打包和压缩

    1. 打包和压缩文件 linux现在经常使用gzip和bzip2要压缩的文件.tar压缩文件. 经常使用的扩展: *.gz   gzip压缩文件 *.bz2  bzip2压缩的文件 *.tar   t ...

  10. JQuery 1.3.2联动获取部门

    Sql       $(document).ready(function(){ $(".dept").bind("click", function () { v ...