I need to repair C# code that was decompiled on with .NET 4. Unfortunately, on my workstation there is only .NET 3.5 installed and that might be the reason why the following code won’t compile:
ReportPage.<>c__DisplayClass26 <>c__DisplayClass = new ReportPage.<>c__DisplayClass26();
What <> construct means here?
There are no c__DisplayClass26 strings anywhere in the code except this line. This might mean that this name is constructed from some metainformation that was missed during decompilation.
The C# compiler sometime has to introduce variables/fields/classes. When he has to do it, he prepends them
<>to their name, so there won’t be a name collision (with the C# compiler, it’s illegal to name something with those two characters). This happens for example for auto generated properties, theyieldkeyword, lambda & anonymous functions/delegates, the newasynckeyword (the one that is introduced in the Async CTP and that will probably be present in C# 5.0)…Now… It’s strange that you have the
c__DisplayClass26only there. Perhaps your decompiler wasn’t up to the par. Try looking at the code withIlSpy.Look at this pastebin: http://pastebin.com/pTRVyVdp (it isn’t mine). There is an example with
c__DisplayClass. In the first half of the text there is the “original” code, in the second half the decompile one. You see, in this case it’s used for a closure. At lines 32/33 there is a[CompilerGenerated] private sealed class <>c__DisplayClass2. You should have it too in your code.Mmmh… IlSpy is a little too much good 🙂 Often it’s able to reconstruct the “original” code from the
CompilerGeneratedcode.