diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..83d2bdb --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,27 @@ +{ + "version": "0.2.0", + "configurations": [ + { + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/Introduction/bin/Debug/netcoreapp3.1/Introduction.dll", + "args": [], + "cwd": "${workspaceFolder}/Introduction", + // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console + "console": "internalConsole", + "stopAtEntry": false + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..7be4609 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,42 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/Introduction/Introduction.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/Introduction/Introduction.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "${workspaceFolder}/Introduction/Introduction.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/Queries/MyLinq.cs b/Queries/MyLinq.cs index efb2118..a0ee4f6 100644 --- a/Queries/MyLinq.cs +++ b/Queries/MyLinq.cs @@ -18,11 +18,9 @@ namespace Queries { if (predicate(item)) { - result.Add(item); + yield return item; } } - - return result; } } } \ No newline at end of file diff --git a/yield_test/Program.cs b/yield_test/Program.cs new file mode 100644 index 0000000..43ccd00 --- /dev/null +++ b/yield_test/Program.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections; + +namespace yield_test +{ + class Program + { + static void Main(string[] args) + { + foreach (var number in GetNumbers()) + { + Console.WriteLine(number); + } + } + + static IEnumerable GetNumbers() + { + yield return 1; + yield return 2; + yield return 3; + } + } +} \ No newline at end of file diff --git a/yield_test/yield_test.csproj b/yield_test/yield_test.csproj new file mode 100644 index 0000000..2c0dacc --- /dev/null +++ b/yield_test/yield_test.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + +