Created
March 14, 2017 17:29
-
-
Save binki/251a7b702823e304d11848404210a18f to your computer and use it in GitHub Desktop.
local method no lamdba decompiled
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Runtime.CompilerServices; | |
namespace LocalFuncCreatesClass | |
{ | |
internal class Program | |
{ | |
private static Func<int> GetNextThing | |
{ | |
get; | |
set; | |
} | |
public Program() | |
{ | |
} | |
[CompilerGenerated] | |
internal static int <Blah>g__next5_0(ref Program.<>c__DisplayClass5_0 variable) | |
{ | |
int num = variable.current + 1; | |
variable.current = num; | |
return num; | |
} | |
private static void Blah() | |
{ | |
Program.<>c__DisplayClass5_0 variable = new Program.<>c__DisplayClass5_0(); | |
Console.WriteLine(Program.<Blah>g__next5_0(ref variable)); | |
} | |
private static void Main(string[] args) | |
{ | |
Program.Blah(); | |
} | |
[CompilerGenerated] | |
private struct <>c__DisplayClass5_0 | |
{ | |
public int current; | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace LocalFuncCreatesClass | |
{ | |
class Program | |
{ | |
static Func<int> GetNextThing { get; set; } | |
static void Main(string[] args) | |
{/* | |
SeparateFunction(); | |
Console.WriteLine(GetNextThing()); | |
Console.WriteLine(GetNextThing()); | |
Console.WriteLine(GetNextThing()); | |
SeparateFunction(); | |
Console.WriteLine(GetNextThing()); | |
Console.WriteLine(GetNextThing()); | |
Console.WriteLine(GetNextThing());*/ | |
Blah(); | |
} | |
/* | |
static void SeparateFunction() | |
{ | |
var current = 2; | |
int next() { return ++current; }; | |
GetNextThing = next; | |
Console.WriteLine(next()); | |
}*/ | |
static void Blah() | |
{ | |
var current = 2; | |
int next() => ++current; | |
Console.WriteLine(next()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment