Click here to Skip to main content
15,905,914 members
Home / Discussions / C#
   

C#

 
Questioncreating an unsafe array in C# Pin
Keith Vitali14-Jun-10 10:45
Keith Vitali14-Jun-10 10:45 
AnswerRe: creating an unsafe array in C# Pin
Luc Pattyn14-Jun-10 10:56
sitebuilderLuc Pattyn14-Jun-10 10:56 
GeneralRe: creating an unsafe array in C# Pin
Keith Vitali15-Jun-10 3:40
Keith Vitali15-Jun-10 3:40 
GeneralRe: creating an unsafe array in C# Pin
Luc Pattyn15-Jun-10 3:45
sitebuilderLuc Pattyn15-Jun-10 3:45 
AnswerRe: creating an unsafe array in C# Pin
DaveyM6914-Jun-10 11:10
professionalDaveyM6914-Jun-10 11:10 
GeneralRe: creating an unsafe array in C# Pin
Luc Pattyn14-Jun-10 11:17
sitebuilderLuc Pattyn14-Jun-10 11:17 
GeneralRe: creating an unsafe array in C# Pin
DaveyM6914-Jun-10 11:49
professionalDaveyM6914-Jun-10 11:49 
GeneralRe: creating an unsafe array in C# Pin
Luc Pattyn14-Jun-10 11:52
sitebuilderLuc Pattyn14-Jun-10 11:52 
Questionusing statement equivalent Pin
Al Beback14-Jun-10 5:06
Al Beback14-Jun-10 5:06 
AnswerRe: using statement equivalent Pin
Eddy Vluggen14-Jun-10 5:16
professionalEddy Vluggen14-Jun-10 5:16 
GeneralRe: using statement equivalent Pin
Al Beback14-Jun-10 5:24
Al Beback14-Jun-10 5:24 
GeneralRe: using statement equivalent Pin
Eddy Vluggen14-Jun-10 5:55
professionalEddy Vluggen14-Jun-10 5:55 
AnswerRe: using statement equivalent Pin
J4amieC14-Jun-10 5:22
J4amieC14-Jun-10 5:22 
GeneralRe: using statement equivalent Pin
Al Beback14-Jun-10 5:51
Al Beback14-Jun-10 5:51 
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 

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.