Click here to Skip to main content
15,896,288 members
Home / Discussions / C#
   

C#

 
AnswerRe: using statement equivalent [modified] Pin
dan!sh 14-Jun-10 5:46
professional dan!sh 14-Jun-10 5:46 
GeneralRe: using statement equivalent Pin
Al Beback14-Jun-10 5:58
Al Beback14-Jun-10 5:58 
GeneralRe: using statement equivalent Pin
dan!sh 14-Jun-10 6:01
professional dan!sh 14-Jun-10 6:01 
GeneralRe: using statement equivalent Pin
Eddy Vluggen14-Jun-10 6:02
professionalEddy Vluggen14-Jun-10 6:02 
GeneralRe: using statement equivalent Pin
dan!sh 14-Jun-10 6:19
professional dan!sh 14-Jun-10 6:19 
GeneralRe: using statement equivalent Pin
Not Active14-Jun-10 7:35
mentorNot Active14-Jun-10 7:35 
GeneralRe: using statement equivalent Pin
Al Beback14-Jun-10 6:04
Al Beback14-Jun-10 6:04 
AnswerRe: using statement equivalent PinPopular
harold aptroot14-Jun-10 6:01
harold aptroot14-Jun-10 6:01 
Wow, everyone got it wrong Smile | :)
Debug or Release?
The debug code (bugs in Reflector corrected by looking at the MSIL)
C#
    SomeIDisposableClass CS$3$0000;
    bool CS$4$0001;
    CS$3$0000 = new SomeIDisposableClass();
Label_0007:
    try
    {
        SomeCode();
        goto Label_0021;
    }
    finally
    {
    Label_0011:
        CS$4$0001 = CS$3$0000 == null;
        if (CS$4$0001)
        {
            goto Label_0020;
        }
        CS$3$0000.Dispose();
    Label_0020:;
    }
Label_0021:;

And yes, it is silly. It's storing the result of the null-check

The Release code
C#
    SomeIDisposableClass CS$3$0000;
    CS$3$0000 = new SomeIDisposableClass();
Label_0006:
    try
    {
        SomeCode();
        goto Label_0017;
    }
    finally
    {
    Label_000D:
        if (CS$3$0000 == null)
        {
            goto Label_0016;
        }
        CS$3$0000.Dispose();
    Label_0016:;
    }
Label_0017:



edit: the rules for goto-within-try are
If the goto statement exits one or more try blocks with associated finally blocks, control is initially transferred to the finally block of the innermost try statement. When and if control reaches the end point of a finally block, control is transferred to the finally block of the next enclosing try statement. This process is repeated until the finally blocks of all intervening try statements have been executed.
GeneralRe: using statement equivalent Pin
Eddy Vluggen14-Jun-10 6:06
professionalEddy Vluggen14-Jun-10 6:06 
GeneralRe: using statement equivalent Pin
harold aptroot14-Jun-10 6:12
harold aptroot14-Jun-10 6:12 
GeneralRe: using statement equivalent Pin
Al Beback14-Jun-10 6:18
Al Beback14-Jun-10 6:18 
Questiondatagrid in Compact Frame work Pin
jashimu14-Jun-10 4:49
jashimu14-Jun-10 4:49 
AnswerMessage Closed Pin
14-Jun-10 7:19
stancrm14-Jun-10 7:19 
GeneralRe: datagrid in Compact Frame work Pin
jashimu18-Jun-10 9:12
jashimu18-Jun-10 9:12 
QuestionFold all code in all of the project with one command Pin
Neo1010114-Jun-10 4:29
Neo1010114-Jun-10 4:29 
AnswerRe: Fold all code in all of the project with one command Pin
R. Giskard Reventlov14-Jun-10 4:58
R. Giskard Reventlov14-Jun-10 4:58 
GeneralRe: Fold all code in all of the project with one command Pin
Neo1010114-Jun-10 8:27
Neo1010114-Jun-10 8:27 
Questionthread and application response Pin
kasraa0009800014-Jun-10 4:29
kasraa0009800014-Jun-10 4:29 
AnswerRe: thread and application response Pin
Luc Pattyn14-Jun-10 4:35
sitebuilderLuc Pattyn14-Jun-10 4:35 
Questiona bad control !!!! Pin
reza assar14-Jun-10 3:52
reza assar14-Jun-10 3:52 
AnswerRe: a bad control !!!! Pin
ostad_mrn14-Jun-10 4:24
ostad_mrn14-Jun-10 4:24 
QuestionUSB Reader Pin
S.Aijaz14-Jun-10 3:44
S.Aijaz14-Jun-10 3:44 
Answercross-post Pin
Luc Pattyn14-Jun-10 3:55
sitebuilderLuc Pattyn14-Jun-10 3:55 
QuestionDemo Deployment Pin
eraser95014-Jun-10 3:17
eraser95014-Jun-10 3:17 
AnswerRe: Demo Deployment Pin
Johnny J.14-Jun-10 3:36
professionalJohnny J.14-Jun-10 3:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.