From 7ac104a9247350e97b0c70bd30059d244a5d81db Mon Sep 17 00:00:00 2001 From: "jason.zhu" Date: Wed, 24 Feb 2021 11:56:17 +1100 Subject: [PATCH] Finished The Power of IEnumerable --- Features/Employee.cs | 8 ++++++++ Features/Features.csproj | 8 ++++++++ Features/Program.cs | 36 ++++++++++++++++++++++++++++++++++++ linq-fundamentals.sln | 14 ++++++++++++++ 4 files changed, 66 insertions(+) create mode 100644 Features/Employee.cs create mode 100644 Features/Features.csproj create mode 100644 Features/Program.cs diff --git a/Features/Employee.cs b/Features/Employee.cs new file mode 100644 index 0000000..0371af2 --- /dev/null +++ b/Features/Employee.cs @@ -0,0 +1,8 @@ +namespace Features +{ + public class Employee + { + public int Id { get; set; } + public string Name { get; set; } + } +} \ No newline at end of file diff --git a/Features/Features.csproj b/Features/Features.csproj new file mode 100644 index 0000000..2c0dacc --- /dev/null +++ b/Features/Features.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + diff --git a/Features/Program.cs b/Features/Program.cs new file mode 100644 index 0000000..fd0e00f --- /dev/null +++ b/Features/Program.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Features +{ + class Program + { + // Modelling a company in this project + static void Main(string[] args) + { + IEnumerable developers = new Employee[] + { + new Employee {Id = 1, Name = "Scott"}, + new Employee {Id = 2, Name = "Chris"} + }; + + List sales = new List() + { + new Employee {Id = 3, Name = "Alex"} + }; + + var enumerator = developers.GetEnumerator(); + + while (enumerator.MoveNext()) + { + Console.WriteLine(enumerator.Current.Name); // .Current return value of current enumerator + } + + foreach (var person in developers) + { + Console.WriteLine(); + } + } + } +} \ No newline at end of file diff --git a/linq-fundamentals.sln b/linq-fundamentals.sln index d920ad3..564275a 100644 --- a/linq-fundamentals.sln +++ b/linq-fundamentals.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 15.0.26124.0 MinimumVisualStudioVersion = 15.0.26124.0 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Introduction", "Introduction\Introduction.csproj", "{AF71FD32-411A-42CD-A69F-DA60FB8E21A9}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Features", "Features\Features.csproj", "{94C9EE4C-0609-464B-9BFF-BA3EED2A7263}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -30,5 +32,17 @@ Global {AF71FD32-411A-42CD-A69F-DA60FB8E21A9}.Release|x64.Build.0 = Release|Any CPU {AF71FD32-411A-42CD-A69F-DA60FB8E21A9}.Release|x86.ActiveCfg = Release|Any CPU {AF71FD32-411A-42CD-A69F-DA60FB8E21A9}.Release|x86.Build.0 = Release|Any CPU + {94C9EE4C-0609-464B-9BFF-BA3EED2A7263}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {94C9EE4C-0609-464B-9BFF-BA3EED2A7263}.Debug|Any CPU.Build.0 = Debug|Any CPU + {94C9EE4C-0609-464B-9BFF-BA3EED2A7263}.Debug|x64.ActiveCfg = Debug|Any CPU + {94C9EE4C-0609-464B-9BFF-BA3EED2A7263}.Debug|x64.Build.0 = Debug|Any CPU + {94C9EE4C-0609-464B-9BFF-BA3EED2A7263}.Debug|x86.ActiveCfg = Debug|Any CPU + {94C9EE4C-0609-464B-9BFF-BA3EED2A7263}.Debug|x86.Build.0 = Debug|Any CPU + {94C9EE4C-0609-464B-9BFF-BA3EED2A7263}.Release|Any CPU.ActiveCfg = Release|Any CPU + {94C9EE4C-0609-464B-9BFF-BA3EED2A7263}.Release|Any CPU.Build.0 = Release|Any CPU + {94C9EE4C-0609-464B-9BFF-BA3EED2A7263}.Release|x64.ActiveCfg = Release|Any CPU + {94C9EE4C-0609-464B-9BFF-BA3EED2A7263}.Release|x64.Build.0 = Release|Any CPU + {94C9EE4C-0609-464B-9BFF-BA3EED2A7263}.Release|x86.ActiveCfg = Release|Any CPU + {94C9EE4C-0609-464B-9BFF-BA3EED2A7263}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection EndGlobal