Created
July 21, 2024 05:55
-
-
Save akeit0/928e52f5dea3678ad060eec0b83a1f4d to your computer and use it in GitHub Desktop.
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
| /* | |
| SharpLab tools in Run mode: | |
| • value.Inspect() | |
| • Inspect.Heap(object) | |
| • Inspect.Stack(value) | |
| • Inspect.MemoryGraph(value1, value2, …) | |
| */ | |
| using System; | |
| using System.Collections; | |
| using System.Linq; | |
| var data = new[] { 1, 2, 3, 4, 5 }.AsEnumerable(); | |
| Action? a = null; | |
| foreach (var x in data) | |
| { | |
| a += () => Console.WriteLine(x); | |
| } | |
| a!(); | |
| a = null; | |
| //C#5より前はそとに変数を定義した | |
| var x2=0; | |
| foreach (var x in data) | |
| { | |
| x2=x; | |
| a += () => Console.WriteLine(x2); | |
| } | |
| a!(); |
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.Collections.Generic; | |
| using System.Diagnostics; | |
| using System.Linq; | |
| using System.Reflection; | |
| using System.Runtime.CompilerServices; | |
| using System.Runtime.InteropServices; | |
| using System.Security; | |
| using System.Security.Permissions; | |
| [assembly: CompilationRelaxations(8)] | |
| [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] | |
| [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue | DebuggableAttribute.DebuggingModes.DisableOptimizations)] | |
| [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] | |
| [assembly: AssemblyVersion("0.0.0.0")] | |
| [module: UnverifiableCode] | |
| [module: RefSafetyRules(11)] | |
| [CompilerGenerated] | |
| internal class Program | |
| { | |
| [CompilerGenerated] | |
| private sealed class <>c__DisplayClass0_0 | |
| { | |
| public int x2; | |
| public Action <>9__1; | |
| internal void <<Main>$>b__1() | |
| { | |
| Console.WriteLine(x2); | |
| } | |
| } | |
| [CompilerGenerated] | |
| private sealed class <>c__DisplayClass0_1 | |
| { | |
| public int x; | |
| internal void <<Main>$>b__0() | |
| { | |
| Console.WriteLine(x); | |
| } | |
| } | |
| private static void <Main>$(string[] args) | |
| { | |
| <>c__DisplayClass0_0 <>c__DisplayClass0_ = new <>c__DisplayClass0_0(); | |
| int[] array = new int[5]; | |
| RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); | |
| IEnumerable<int> enumerable = Enumerable.AsEnumerable(array); | |
| Action action = null; | |
| IEnumerator<int> enumerator = enumerable.GetEnumerator(); | |
| try | |
| { | |
| while (enumerator.MoveNext()) | |
| { | |
| <>c__DisplayClass0_1 <>c__DisplayClass0_2 = new <>c__DisplayClass0_1(); | |
| <>c__DisplayClass0_2.x = enumerator.Current; | |
| action = (Action)Delegate.Combine(action, new Action(<>c__DisplayClass0_2.<<Main>$>b__0)); | |
| } | |
| } | |
| finally | |
| { | |
| if (enumerator != null) | |
| { | |
| enumerator.Dispose(); | |
| } | |
| } | |
| action(); | |
| action = null; | |
| <>c__DisplayClass0_.x2 = 0; | |
| IEnumerator<int> enumerator2 = enumerable.GetEnumerator(); | |
| try | |
| { | |
| while (enumerator2.MoveNext()) | |
| { | |
| int num = (<>c__DisplayClass0_.x2 = enumerator2.Current); | |
| action = (Action)Delegate.Combine(action, <>c__DisplayClass0_.<>9__1 ?? (<>c__DisplayClass0_.<>9__1 = new Action(<>c__DisplayClass0_.<<Main>$>b__1))); | |
| } | |
| } | |
| finally | |
| { | |
| if (enumerator2 != null) | |
| { | |
| enumerator2.Dispose(); | |
| } | |
| } | |
| action(); | |
| } | |
| } | |
| [CompilerGenerated] | |
| internal sealed class <PrivateImplementationDetails> | |
| { | |
| [StructLayout(LayoutKind.Explicit, Pack = 1, Size = 20)] | |
| private struct __StaticArrayInitTypeSize=20 | |
| { | |
| } | |
| internal static readonly __StaticArrayInitTypeSize=20 4F6ADDC9659D6FB90FE94B6688A79F2A1FA8D36EC43F8F3E1D9B6528C448A384/* Not supported: data(01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00) */; | |
| } |
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
| { | |
| "version": 1, | |
| "target": "C#", | |
| "mode": "Debug", | |
| "branch": "features-ParamsCollections" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment