Skip to content

Commit a910d3f

Browse files
CopilotBillWagnerIEvangelist
authored
Add using statement guidance for extension methods in LINQ tutorial (#47051)
* Initial plan * Add using statement guidance for extension methods in LINQ tutorial Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com> * Fix file name formatting to use italics for Program.cs Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com> Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>
1 parent 299cc19 commit a910d3f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

docs/csharp/tutorials/working-with-linq.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ using System.Linq;
4747

4848
If these three lines (`using` directives) aren't at the top of the file, your program might not compile.
4949

50+
> [!TIP]
51+
> For this tutorial, you can organize your code in a namespace called `LinqFaroShuffle` to match the sample code, or you can use the default global namespace. If you choose to use a namespace, make sure all your classes and methods are consistently within the same namespace, or add appropriate `using` statements as needed.
52+
5053
Now that you have all of the references that you'll need, consider what constitutes a deck of cards. Commonly, a deck of playing cards has four suits, and each suit has thirteen values. Normally, you might consider creating a `Card` class right off the bat and populating a collection of `Card` objects by hand. With LINQ, you can be more concise than the usual way of dealing with creating a deck of cards. Instead of creating a `Card` class, you can create two sequences to represent suits and ranks, respectively. You'll create a really simple pair of [*iterator methods*](../iterators.md#enumeration-sources-with-iterator-methods) that will generate the ranks and suits as <xref:System.Collections.Generic.IEnumerable%601>s of strings:
5154

5255
```csharp
@@ -160,6 +163,9 @@ namespace LinqFaroShuffle
160163
}
161164
```
162165

166+
> [!NOTE]
167+
> If you're using an editor other than Visual Studio (such as Visual Studio Code), you might need to add `using LinqFaroShuffle;` to the top of your _Program.cs_ file for the extension methods to be accessible. Visual Studio automatically adds this using statement, but other editors might not.
168+
163169
Look at the method signature for a moment, specifically the parameters:
164170

165171
```csharp

0 commit comments

Comments
 (0)