-
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
Showing
2 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,48 @@ | ||
internal class Program | ||
{ | ||
private static void Main(string[] args) | ||
{ | ||
var names = new List<string> {"john", "jack", "jeff", "jeremy", "jason"}; | ||
var nameLengths = names.Select(name => name.Length); | ||
var firstLetters = names.Select(name => name[0]); | ||
|
||
foreach(var length in nameLengths) { | ||
Console.WriteLine(length); | ||
} | ||
|
||
Console.WriteLine(new String('-', 15)); | ||
|
||
foreach(var letter in firstLetters) { | ||
Console.WriteLine(letter); | ||
} | ||
} | ||
|
||
private static void example3() { | ||
var names = new List<string> {"john", "jack", "jeff", "jeremy", "jason"}; | ||
names.Sort(); | ||
|
||
foreach(var name in names) { | ||
Console.WriteLine(name); | ||
} | ||
} | ||
|
||
private static void example2() { | ||
var names = new List<string> {"john", "jack", "jeff", "jeremy", "jason"}; | ||
foreach(var name in names) { | ||
Console.WriteLine(name); | ||
} | ||
} | ||
|
||
private static void example1() { | ||
var names = new List<string>(); | ||
names.Add("john"); | ||
names.Add("jack"); | ||
names.Add("jeff"); | ||
names.Add("jeremy"); | ||
names.Add("jason"); | ||
|
||
foreach(var name in names) { | ||
Console.WriteLine(name); | ||
} | ||
} | ||
} |
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,11 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<RootNamespace>app9_list</RootNamespace> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |