Skip to content

Update LINQ tutorial sample code to match tutorial progression #47671

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 25 additions & 39 deletions samples/snippets/csharp/getting-started/console-linq/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,56 +4,42 @@

namespace LinqFaroShuffle
{
#region snippet2
public enum Suit
{
Clubs,
Diamonds,
Hearts,
Spades
}
#endregion

#region snippet3
public enum Rank
{
Two,
Three,
Four,
Five,
Six,
Seven,
Eight,
Nine,
Ten,
Jack,
Queen,
King,
Ace
}
#endregion

public class Program
{
#region snippet4
static IEnumerable<Suit> Suits() => (Enum.GetValues(typeof(Suit)) as IEnumerable<Suit>)!;
static IEnumerable<string> Suits()
{
yield return "clubs";
yield return "diamonds";
yield return "hearts";
yield return "spades";
}
#endregion

#region snippet5
static IEnumerable<Rank> Ranks() => (Enum.GetValues(typeof(Rank)) as IEnumerable<Rank>)!;
static IEnumerable<string> Ranks()
{
yield return "two";
yield return "three";
yield return "four";
yield return "five";
yield return "six";
yield return "seven";
yield return "eight";
yield return "nine";
yield return "ten";
yield return "jack";
yield return "queen";
yield return "king";
yield return "ace";
}
#endregion

#region snippet1
public static void Main(string[] args)
{
IEnumerable<Suit>? suits = Suits();
IEnumerable<Rank>? ranks = Ranks();

if ((suits is null) || (ranks is null))
return;

var startingDeck = (from s in suits.LogQuery("Suit Generation")
from r in ranks.LogQuery("Value Generation")
var startingDeck = (from s in Suits().LogQuery("Suit Generation")
from r in Ranks().LogQuery("Rank Generation")
select new { Suit = s, Rank = r })
.LogQuery("Starting Deck")
.ToArray();
Expand Down

This file was deleted.