pluralsight-linq-fundamentals/Features/Program.cs

44 lines
1.2 KiB
C#
Raw Normal View History

2021-02-24 11:56:17 +11:00
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
2021-02-24 11:56:17 +11:00
namespace Features
{
class Program
{
// Modelling a company in this project
static void Main(string[] args)
{
IEnumerable<Employee> developers = new Employee[]
{
new Employee {Id = 1, Name = "Scott"},
new Employee {Id = 2, Name = "Chris"}
};
List<Employee> sales = new List<Employee>()
{
new Employee {Id = 3, Name = "Alex"}
};
2021-02-24 13:49:26 +11:00
Console.WriteLine(sales.MyLinqCount());
2021-02-24 11:56:17 +11:00
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();
}
foreach (var employee in developers.Where(x => x.Name.StartsWith("S")))
{
Console.WriteLine(employee.Name);
}
2021-02-24 11:56:17 +11:00
}
}
}