E
E
Eugene2019-11-26 10:04:10
.NET
Eugene, 2019-11-26 10:04:10

How to see what C# syntactic sugar expands into?

Everywhere you can read that some using

using (FileStream fs = new FileStream(@"C:\tmp\text.txt", FileMode.Open))
{
}

unfolds into something like
FileStream fs = new FileStream(@"C:\tmp\text.txt", FileMode.Open);
try
{
}
finally
{
    if (fs != null)
        ((IDisposable)fs).Dispose();
}

Are there any ways to see for yourself what is unfolding into what? As far as I understand, ildasm already gives an assembler, but this is not what I need.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
freeExec, 2019-11-26
@tw1ggyz

for example

Y
yuopi, 2019-11-26
@yuopi

ildasm doesn't give assembly code, it gives IL code. Pretty readable, try
In the book CLR via c# that how it works is told through this program

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question