Click here to Skip to main content
15,903,856 members
Home / Discussions / C#
   

C#

 
QuestionTrackBar Pin
Nicolás Marzoni14-Jun-10 17:32
Nicolás Marzoni14-Jun-10 17:32 
AnswerRe: TrackBar Pin
Calla14-Jun-10 19:32
Calla14-Jun-10 19:32 
GeneralRe: TrackBar Pin
Nicolás Marzoni15-Jun-10 1:28
Nicolás Marzoni15-Jun-10 1:28 
GeneralRe: TrackBar Pin
DaveyM6915-Jun-10 1:31
professionalDaveyM6915-Jun-10 1:31 
GeneralRe: TrackBar Pin
Nicolás Marzoni15-Jun-10 1:36
Nicolás Marzoni15-Jun-10 1:36 
GeneralRe: TrackBar Pin
DaveyM6915-Jun-10 2:39
professionalDaveyM6915-Jun-10 2:39 
GeneralRe: TrackBar Pin
DaveyM6915-Jun-10 2:40
professionalDaveyM6915-Jun-10 2:40 
GeneralRe: TrackBar - Long post alert! Pin
DaveyM6915-Jun-10 10:17
professionalDaveyM6915-Jun-10 10:17 
QuestionAsp.Net MVC2 in VS 2010 Pin
Darrall14-Jun-10 12:03
Darrall14-Jun-10 12:03 
AnswerRe: Asp.Net MVC2 in VS 2010 Pin
Al Beback14-Jun-10 17:15
Al Beback14-Jun-10 17:15 
GeneralRe: Asp.Net MVC2 in VS 2010 Pin
Darrall15-Jun-10 3:37
Darrall15-Jun-10 3:37 
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 
Al Beback wrote:
that article doesn't address my specific example where a variable is not explicitly declared inside the using statement.


Ah, my bad; it does almost the same the same thing, with the difference that you don't have a reference to your class. It still creates a class, disposing it in the finally.
C#
public static void Main(string[] args)
{
    using (new SomeIDisposableClass())
    {
        Console.WriteLine("Hello World!");
    }
    Console.ReadKey(true);
}

..translates to..
IL
.method public hidebysig static 
  void Main(string[] args) cil managed
{
    .entrypoint
    .maxstack 2
    .locals init (
        [0] class using_test.SomeIDisposableClass CS$3$0000,
        [1] bool CS$4$0001)
    L_0000: nop 
    L_0001: newobj instance void 
              using_test.SomeIDisposableClass::.ctor()
    L_0006: stloc.0 
    L_0007: nop 
    L_0008: ldstr "Hello World!"
    L_000d: call void [mscorlib]System.Console::WriteLine(string)
    L_0012: nop 
    L_0013: nop 
    L_0014: leave.s L_0026
    L_0016: ldloc.0 
    L_0017: ldnull 
    L_0018: ceq 
    L_001a: stloc.1 
    L_001b: ldloc.1 
    L_001c: brtrue.s L_0025
    L_001e: ldloc.0 
    L_001f: callvirt instance void 
              [mscorlib]System.IDisposable::Dispose()
    L_0024: nop 
    L_0025: endfinally 
    L_0026: nop 
    L_0027: ldc.i4.1 
    L_0028: call valuetype 
              [mscorlib]System.ConsoleKeyInfo 
              [mscorlib]System.Console::ReadKey(bool)
    L_002d: pop 
    L_002e: ret 
    .try L_0007 to L_0016 finally handler L_0016 to L_0026
}

I are Troll Suspicious | :suss:

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 

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.