Re: runtime stack
- From: Joshua Flanagan <josh@xxxxxxxxxx>
- Date: Sat, 23 Apr 2005 00:36:44 -0500
There is no difference. They will both produce identical IL code.
This isn't related to the stack. The stack would be relevant if you were concerned about the number of variables you are using within a method.
If you want to see for yourself that they are exactly the same (and learn how to figure these things out), copy the following text to a file (test.cs):
using System;
public class StackTest {
public void FirstTry(string varone){
if(varone != null)
if(varone != "")
dosomething();
}
public void SecondTry(string varone){
if(varone != null && varone!= "")
dosomething();
} public void dosomething(){
Console.WriteLine("hello");
}
}Compile from the command line: csc /t:library /out:test.dll test.cs
Load the library in the IL Disassembler: ildasm test.dll
Double click on FirstTry. Double click on SecondTry. Compare the contents of the 2 windows that popped up. The instructions are the same.
Joshua Flanagan http://flimflan.com/blog .
- Follow-Ups:
- Re: runtime stack
- From: Chance Hopkins
- Re: runtime stack
- References:
- runtime stack
- From: Chance Hopkins
- runtime stack
- Prev by Date: Re: runtime stack
- Next by Date: Re: ReadXML True vs true
- Previous by thread: Re: runtime stack
- Next by thread: Re: runtime stack
- Index(es):
Relevant Pages
|