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 ...
随机推荐
- qt之fillder抓包(QT网络版有一些具体的坑)
最近项目中使用到了Qt的网络库,在用的过程中也发现了不少坑和问题,本文仅仅作为记录,方便日后查阅. 因为我们整个客户端的gui都是使用qt来完成的,心想qt既然有网络库,而且真心觉着qt封装的控 ...
- 转:sql语句中GROUP BY 和 HAVING和使用 count()
在开发时,我们经常会遇到以“累计(count)”或是“累加(sum)”为条件的查询.比如user_num表: id user num 1 a 3 2 a 4 3 b 5 4 b 7 例1:查询出现 ...
- bzoj4546-codechef XRQRS(可持久化Trie)
中文题题意我就不说了 解析: 可持久化Trie的模板题,详见注释 代码 #include<cstdio> #include<cstring> #include<strin ...
- jquery插件-自定义select
由于原生select在各个浏览器的样式不统一,特别是在IE67下直接不可以使用样式控制,当PM让你做一个样式的时候,那是相当的痛苦.最好的办法就是使用自定义样式仿select效果.这里写了一个 ...
- python中自定义类对象json字符串化的方法
1. 用 json 或者simplejson 就可以 2.定义转换函数: def convert_to_builtin_type(obj): print 'default(', repr(obj), ...
- poj 2229 Sumsets DP
题意:给定一个整数N (1<= N <= 1000000),求出以 N为和 的式子有多少个,式子中的加数只能有2的幂次方组成 如5 : 1+1+1+1+1.1+1+1+2.1+2+2.1+ ...
- 《Java程序员面试笔试宝典》之字符串创建与存储的机制是什么
在Java语言中,字符串起着非常重要的作用,字符串的声明与初始化主要有如下两种情况: (1) 对于String s1=new String("abc")语句与Strin ...
- 关于safari上的select宽高问题小技,自定义下拉框
之前一直用windows做开发,最近换了个mac,在几经折腾之下,安装完了各种开发工具,IDE等,然后欣然打开自己正在开发的网站.突然发现mac上所有的下拉框都变了,都是默认样式,无论padding, ...
- JAVA读、写EXCEL文件
採用jxl.jar包,网上下载,百度一下到出都是.希望能够帮助到大家. 接下来直接贴代码: <span style="font-size:18px;"> public ...
- HTTP协议4之缓存--转
HTTP协议提供了非常强大的缓存机制, 了解这些缓存机制,对提高网站的性能非常有帮助. 缓存的概念 缓存这个东西真的是无处不在, 有浏览器端的缓存, 有服务器端的缓存,有代理服务器的缓存, 有ASP. ...