簡體   English   中英

使用Mono在Linux上查看C#代碼的CIL

[英]View CIL of C# code on Linux with mono

我想在Linux上檢查以下C#源文件的生成的CIL代碼:

using System;
namespace PrintPrimes
{
    class Algorithm
    {
        static bool IsPrime(int p)
        {
            for (int i=2;i<p;i++)
            {
                for (int j=i;j<p;j++)
                {
                    if (i*j == p)
                    {
                        return false;
                    }
                }
            }
            return true;
        }
        static void Main() 
        {
            for (int p=2;p<=20;p++)
            {
                if (IsPrime(p))
                {
                    Console.WriteLine(p + " ");
                }
            }
        }
    }
}

當我編譯並運行它時,一切都很好:

$ mcs -out:PrintPrimes PrintPrimes.cs
$ ./PrintPrimes
2 
3 
5 
7 
11 
13 
17 
19 

但是,如何獲得人類可讀的CIL輸出?

Mono反匯編程序,從程序集中提取IL代碼:

monodis FILE-name

完整的參考資料可以在這里找到: https : //www.mono-project.com/docs/tools+libraries/tools/monodis/

分解/匯編CIL代碼(Mono項目)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM