IL assembly language to read console input and convert to integer

Create a new testcvt.il;

.assembly extern mscorlib {}
 
 .assembly Test
 {
     .ver 1:0:1:0
 }
 .module test.exe
  
 .method static void main() cil managed
 {
     .maxstack 1
     .entrypoint

    ldstr "\n请输入一个数字:"
    call void [mscorlib]System.Console::Write(string)
    call string [mscorlib]System.Console::ReadLine()
    call int32 [mscorlib]System.Convert::ToInt32(string)     
    call void [mscorlib]System.Console::Write (int32)
 
     ret
 }

I still don't understand the content of IL assembly; I checked the online information, the above code should be, prompt to enter a number, and then read it into the console input, it is read as a string, then converted to an integer, and then output this integer;

Build and run to see; as follows; 

 It runs according to the meaning it understands; ignore the errors of Chinese characters;

It is not clear where to put the characters that are read in, and where to put them when they are converted into integers, and there is time to continue;

Guess you like

Origin blog.csdn.net/bcbobo21cn/article/details/132123879