Add project files.
This commit is contained in:
parent
c26b064de6
commit
8c9d472617
|
@ -0,0 +1,25 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.3.32811.315
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EnumerablePerformance", "EnumerablePerformance\EnumerablePerformance.csproj", "{37DC452D-B053-4540-8AD4-DA7CB6A7E90B}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{37DC452D-B053-4540-8AD4-DA7CB6A7E90B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{37DC452D-B053-4540-8AD4-DA7CB6A7E90B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{37DC452D-B053-4540-8AD4-DA7CB6A7E90B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{37DC452D-B053-4540-8AD4-DA7CB6A7E90B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {B3DD8F12-987C-48AE-8397-DB44558BF61B}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
|
@ -0,0 +1,10 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
|
@ -0,0 +1,80 @@
|
||||||
|
/*
|
||||||
|
* This method of enumerables makes it so that GetCustomers() is run twice,
|
||||||
|
* doing the same read line and return of the same data, for two different
|
||||||
|
* proccesses. Since customers is not immediately used, the function isn't
|
||||||
|
* happening yet. Count() causes the first run of GetCustomers() in order
|
||||||
|
* to get the customers to receive the count. GetCustomers() is then rerun
|
||||||
|
* during the Console.WriteLine() where it retrieves each customer.
|
||||||
|
*/
|
||||||
|
|
||||||
|
Console.WriteLine("_______________________________________");
|
||||||
|
Console.WriteLine("STANDARD");
|
||||||
|
Console.WriteLine();
|
||||||
|
|
||||||
|
|
||||||
|
var customers = GetCustomers();
|
||||||
|
|
||||||
|
|
||||||
|
var count = customers.Count();
|
||||||
|
Console.WriteLine($"\tThere are {count} customers");
|
||||||
|
|
||||||
|
foreach(var customer in customers)
|
||||||
|
{
|
||||||
|
Console.WriteLine("\t" + customer);
|
||||||
|
}
|
||||||
|
Console.WriteLine();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* By retrieving a list of the items from the function, you mitigate the issue
|
||||||
|
* of returning to the function later, as the data is saved as a list to a variable.
|
||||||
|
*/
|
||||||
|
|
||||||
|
Console.WriteLine("_______________________________________");
|
||||||
|
Console.WriteLine("ENHANCED-PERFORMANCE");
|
||||||
|
Console.WriteLine();
|
||||||
|
|
||||||
|
|
||||||
|
var customersList = GetCustomersList();
|
||||||
|
|
||||||
|
var countList = customersList.Count();
|
||||||
|
Console.WriteLine($"\tThere are {countList} customers");
|
||||||
|
|
||||||
|
foreach (var customer in customersList)
|
||||||
|
{
|
||||||
|
Console.WriteLine("\t" + customer);
|
||||||
|
}
|
||||||
|
Console.WriteLine();
|
||||||
|
|
||||||
|
|
||||||
|
// Functions
|
||||||
|
|
||||||
|
IEnumerable<Customer> GetCustomers()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Inside GetCustomers()");
|
||||||
|
var lines = File.ReadAllLines("../../../customers.csv"); //For some reason the program starts an extra 2 deep into bin/Debug
|
||||||
|
|
||||||
|
foreach(var line in lines)
|
||||||
|
{
|
||||||
|
var splitLine = line.Split(",");
|
||||||
|
yield return new Customer(splitLine[0], int.Parse(splitLine[1]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerable<Customer> GetCustomersList()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Inside GetCustomersList()");
|
||||||
|
var list = new List<Customer>();
|
||||||
|
var lines = File.ReadAllLines("../../../customers.csv"); //For some reason the program starts an extra 2 deep into bin/Debug
|
||||||
|
|
||||||
|
foreach (var line in lines)
|
||||||
|
{
|
||||||
|
var splitLine = line.Split(",");
|
||||||
|
list.Add(new Customer(splitLine[0], int.Parse(splitLine[1])));
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
record Customer(string Fullname, int Age);
|
|
@ -0,0 +1,3 @@
|
||||||
|
Kira Jiroux,25
|
||||||
|
Jira Kiroux,24
|
||||||
|
Jairik Roux,59
|
|
Loading…
Reference in New Issue