From 69f41a89342d78b33679dd22596cad660b7ff9c0 Mon Sep 17 00:00:00 2001 From: Olabamiji Oyetubo <60369677+bigboybamo@users.noreply.github.com> Date: Tue, 11 Jun 2024 23:36:22 +0100 Subject: [PATCH 1/5] Update access-modifiers.md Added description for file access type modifier --- .../programming-guide/classes-and-structs/access-modifiers.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/csharp/programming-guide/classes-and-structs/access-modifiers.md b/docs/csharp/programming-guide/classes-and-structs/access-modifiers.md index 5543714e1a752..2fc42d93fb2ac 100644 --- a/docs/csharp/programming-guide/classes-and-structs/access-modifiers.md +++ b/docs/csharp/programming-guide/classes-and-structs/access-modifiers.md @@ -73,6 +73,8 @@ To set the access level for a `class` or `struct` member, add the appropriate ke Finalizers can't have accessibility modifiers. Members of an `enum` type are always `public`, and no access modifiers can be applied. +The `file` access modifier is allowed only on top-level (non-nested) type declarations. + ## C# language specification [!INCLUDE[CSharplangspec](~/includes/csharplangspec-md.md)] From fb080e166300041c0deb7c4c0ad6aec67a518c9b Mon Sep 17 00:00:00 2001 From: Olabamiji Oyetubo <60369677+bigboybamo@users.noreply.github.com> Date: Tue, 3 Feb 2026 18:45:41 +0100 Subject: [PATCH 2/5] Introduce Student class for collection querying example Added a Student class to demonstrate merging data from collections. --- docs/csharp/linq/how-to-query-collections.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/csharp/linq/how-to-query-collections.md b/docs/csharp/linq/how-to-query-collections.md index 3d661a92524e3..222e954a27db1 100644 --- a/docs/csharp/linq/how-to-query-collections.md +++ b/docs/csharp/linq/how-to-query-collections.md @@ -47,6 +47,24 @@ The second, *scores.csv*, contains student IDs in the first column, followed by The following example shows how to use a named record `Student` to store merged data from two in-memory collections of strings that simulate spreadsheet data in .csv format. The ID is used as the key to map students to their scores. +```csharp +public class Student +{ + public int ID { get; set; } + public string FirstName { get; set; } + public string LastName { get; set; } + public int[] ExamScores { get; set; } + + public Student(int ID, string FirstName, string LastName, int[] ExamScores) + { + this.ID = ID; + this.FirstName = FirstName; + this.LastName = LastName; + this.ExamScores = ExamScores; + } +} +``` + :::code language="csharp" source="./snippets/HowToCollections/Program.cs" id="PopulateCollection"::: In the [select](../language-reference/keywords/select-clause.md) clause, each new `Student` object is initialized from the data in the two sources. From 0d46d002196d762c0a30b2e5873e08745c8526ce Mon Sep 17 00:00:00 2001 From: Olabamiji Oyetubo <60369677+bigboybamo@users.noreply.github.com> Date: Tue, 3 Feb 2026 23:07:13 +0100 Subject: [PATCH 3/5] Remove Student class definition from LINQ example Removed the definition of the Student class from the documentation. --- docs/csharp/linq/how-to-query-collections.md | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/docs/csharp/linq/how-to-query-collections.md b/docs/csharp/linq/how-to-query-collections.md index 222e954a27db1..3d661a92524e3 100644 --- a/docs/csharp/linq/how-to-query-collections.md +++ b/docs/csharp/linq/how-to-query-collections.md @@ -47,24 +47,6 @@ The second, *scores.csv*, contains student IDs in the first column, followed by The following example shows how to use a named record `Student` to store merged data from two in-memory collections of strings that simulate spreadsheet data in .csv format. The ID is used as the key to map students to their scores. -```csharp -public class Student -{ - public int ID { get; set; } - public string FirstName { get; set; } - public string LastName { get; set; } - public int[] ExamScores { get; set; } - - public Student(int ID, string FirstName, string LastName, int[] ExamScores) - { - this.ID = ID; - this.FirstName = FirstName; - this.LastName = LastName; - this.ExamScores = ExamScores; - } -} -``` - :::code language="csharp" source="./snippets/HowToCollections/Program.cs" id="PopulateCollection"::: In the [select](../language-reference/keywords/select-clause.md) clause, each new `Student` object is initialized from the data in the two sources. From 9f8692c0dda52109d791b42346bb9c2f73fd9b9a Mon Sep 17 00:00:00 2001 From: Olabamiji Oyetubo <60369677+bigboybamo@users.noreply.github.com> Date: Tue, 3 Feb 2026 23:12:13 +0100 Subject: [PATCH 4/5] Format Student record definition for clarity --- docs/csharp/linq/snippets/HowToCollections/Program.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/csharp/linq/snippets/HowToCollections/Program.cs b/docs/csharp/linq/snippets/HowToCollections/Program.cs index 0e7562518381f..06c64e5396fa6 100644 --- a/docs/csharp/linq/snippets/HowToCollections/Program.cs +++ b/docs/csharp/linq/snippets/HowToCollections/Program.cs @@ -270,4 +270,7 @@ where student.ExamScores[0] > 95 Console.WriteLine(s.LastName + ": " + s.ExamScores[0]); // } -public record Student(string FirstName, string LastName, int[] ExamScores, int ID=0); + +// +public record Student(string FirstName, string LastName, int[] ExamScores, int ID = 0); +// From 5009fcf4f8c93c66f47014648762267eb5bb9c9f Mon Sep 17 00:00:00 2001 From: Olabamiji Oyetubo <60369677+bigboybamo@users.noreply.github.com> Date: Tue, 3 Feb 2026 23:13:52 +0100 Subject: [PATCH 5/5] Enhance LINQ documentation with code examples Added code snippets for Student record and collection population. --- docs/csharp/linq/how-to-query-collections.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/csharp/linq/how-to-query-collections.md b/docs/csharp/linq/how-to-query-collections.md index 3d661a92524e3..67135645651ea 100644 --- a/docs/csharp/linq/how-to-query-collections.md +++ b/docs/csharp/linq/how-to-query-collections.md @@ -47,6 +47,8 @@ The second, *scores.csv*, contains student IDs in the first column, followed by The following example shows how to use a named record `Student` to store merged data from two in-memory collections of strings that simulate spreadsheet data in .csv format. The ID is used as the key to map students to their scores. +:::code language="csharp" source="./snippets/HowToCollections/Program.cs" id="StudentDefinition"::: + :::code language="csharp" source="./snippets/HowToCollections/Program.cs" id="PopulateCollection"::: In the [select](../language-reference/keywords/select-clause.md) clause, each new `Student` object is initialized from the data in the two sources.