C# 如何查看源程序的IL代码
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代码的更多相关文章
- C#程序集系列02,使用记事本查看可执行程序集的IL代码
继续上一篇"C#程序集系列01,用记事本编写C#,IL代码,用DOS命令编译程序集,运行程序",在F盘的as文件夹中已经有了若干程序集.本篇体验使用记事本查看可执行程序集的IL代码 ...
- CLR基础,CLR运行过程,使用dos命令创建、编译、运行C#文件,查看IL代码
CLR是Common Language Runtime的缩写,是.NET程序集或可执行程序运行的一个虚拟环境.CLR用于管理托管代码,但是它本身是由非托管代码编写的,并不是一个包含了托管代码的程序集, ...
- 读懂IL代码就这么简单 (一)
一前言 感谢 @冰麟轻武 指出文章的错误之处,现已更正 对于IL代码没了解之前总感觉很神奇,初一看完全不知所云,只听高手们说,了解IL代码你能更加清楚的知道你的代码是如何运行相互调用的,此言一出不明觉 ...
- 读懂IL代码就这么简单
原文地址:http://www.cnblogs.com/zery/p/3366175.html 一前言 感谢 @冰麟轻武 指出文章的错误之处,现已更正 对于IL代码没了解之前总感觉很神奇,初一看完全不 ...
- 读懂IL代码(一)
以前刚开始学C#的时候,总有高手跟我说,去了解一下IL代码吧,看懂了你能更加清楚的知道你写出来的代码是如何运行互相调用的,可是那时候没去看,后来补的,其实感觉也不晚.刚开始看IL代码的时候,感觉非常吃 ...
- 详解.NET IL代码(一)
本文主要介绍IL代码,内容大部分来自网上,进行整理合并的. 一.IL简介 为什么要了解IL代码? 如果想学好.NET,IL是必须的基础,IL代码是.NET运行的基础,当我们对运行结果有异议的时候,可以 ...
- 如何解读IL代码
如何解读IL代码 关于IL代码,我有将从三个方面去揭开它神秘的面纱.IL代码是什么?我们为什么要去读懂IL代码?我们如何去读懂IL代码?这三个问题的解答,将是我解读IL代码的整体思路. IL代码是什么 ...
- 【转载】读懂IL代码就这么简单 (一)
一前言 感谢 @冰麟轻武 指出文章的错误之处,现已更正 对于IL代码没了解之前总感觉很神奇,初一看完全不知所云,只听高手们说,了解IL代码你能更加清楚的知道你的代码是如何运行相互调用的,此言一出不明觉 ...
- 详解.NET IL代码
一.前言 IL是什么? Intermediate Language (IL)微软中间语言 C#代码编译过程? C#源代码通过LC转为IL代码,IL主要包含一些元数据和中间语言指令: JIT编译器把IL ...
随机推荐
- LeetCode_Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could negativ ...
- smarty模板执行原理
为了实现程序的业务逻辑和内容表现页面的分离从而提高开发速度,php 引入了模板引擎的概念,php 模板引擎里面最流行的可以说是smarty了,smarty因其功能强大而且速度快而被广大php web开 ...
- JSTL核心标签库学习笔记
写的很简单,不一定会有用,如果想要详细的话,建议看API啊--- 不过在这里推荐一个地址,http://www.yiibai.com/jstl/ 希望对你们有帮助啊,很好的教材啊 1.<c:i ...
- proxy 利用get拦截,实现一个生成各种DOM节点的通用函数dom。
const dom = new Proxy({}, { get(target, property) { return function(attrs = {}, ...children) { const ...
- Android将第三方jar打包进apk
转自:http://blog.csdn.net/liushaogeng/article/details/6641704 使用第三方jar包 除了我以下介绍的方法,别的方法我基本上都试验过,均会出现编译 ...
- 30款基本UX工具 - 思维流程工具 & 原型工具
来源:GBin1.com 现在的开发人员在建造网站时,注重的是布局和技术特性,但是往往忽略了更重要的一点,那就是用户体验. 如 果用户在使用的时候,不能简单清楚的知道该要如何操作,那么他们一定会选择另 ...
- [Immutable,js] Iterating Over an Immutable.js Map()
Immutable.js provides several methods to iterate over an Immutable.Map(). These also apply to the ot ...
- android——使用自带录屏工具进行屏幕录像
在做开源项目的时候,想传一个gif效果图上去.但是,要有连贯的动画效果.所以,就想到先录制视频,然后视频转gif.但是,用第三录屏软件总是不完美. 那么,怎么办呢? android4.4 提供了自带录 ...
- C++实现二叉树的基本操作
#include <iostream> #include <stack> #include <queue> using std::cin; using std::c ...
- PHP学习笔记二十七【重写】
<?php // class Animal{ public $name; protected $price; function cry(){ echo "动物在叫....<br/ ...