forked from ItalyDotNet/MyCourse
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Moreno Gentili
committed
Apr 9, 2019
1 parent
4b02eb9
commit 2cee6d2
Showing
3 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": ".NET Script Debug", | ||
"type": "coreclr", | ||
"request": "launch", | ||
"program": "dotnet", | ||
"args": [ | ||
"exec", | ||
"C:/Users/brigh/.dotnet/tools/.store/dotnet-script/0.28.0/dotnet-script/0.28.0/tools/netcoreapp2.1/any/dotnet-script.dll", | ||
"${file}" | ||
], | ||
"cwd": "${workspaceRoot}", | ||
"stopAtEntry": true | ||
} | ||
] | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
//Per fare il debug di questi esempi, devi prima installare il global tool dotnet-script con questo comando: | ||
//dotnet tool install -g dotnet-script | ||
//Trovi altre istruzioni nel file /scripts/readme.md | ||
class Apple { | ||
public string Color { get; set; } | ||
public int Weight { get; set; } //In grammi | ||
} | ||
|
||
List<Apple> apples = new List<Apple> { | ||
new Apple { Color = "Red", Weight = 180 }, | ||
new Apple { Color = "Green", Weight = 195 }, | ||
new Apple { Color = "Red", Weight = 190 }, | ||
new Apple { Color = "Green", Weight = 185 }, | ||
}; | ||
|
||
//ESEMPIO #1: Ottengo i pesi delle mele rosse | ||
IEnumerable<int> weightsOfRedApples = apples | ||
.Where(apple => apple.Color == "Red") | ||
.Select(apple => apple.Weight); | ||
|
||
//ESEMPIO #2: Calcolo la media dei pesi ottenuti | ||
double average = weightsOfRedApples.Average(); | ||
Console.WriteLine(); | ||
|
||
//ESERCIZIO #1: Qual è il peso minimo delle 4 mele? | ||
//int minimumWeight = apples...; | ||
|
||
//ESERCIZIO #2: Di che colore è la mela che pesa 190 grammi? | ||
//string color = apples...; | ||
|
||
//ESERCIZIO #3: Quante sono le mele rosse? | ||
//int redAppleCount = apples...; | ||
|
||
//ESERCIZIO #4: Qual è il peso totale delle mele verdi? | ||
//int totalWeight = apples...; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"script": { | ||
"enableScriptNuGetReferences": true, | ||
"defaultTargetFramework": "netcoreapp2.1" | ||
} | ||
} |