Skip to content

Commit 69be370

Browse files
committed
Read-through and update
I made a few editorial changes while doing a final proofread.
1 parent 8d95b30 commit 69be370

6 files changed

Lines changed: 22 additions & 30 deletions

File tree

docs/csharp/fundamentals/program-structure/index.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ helpviewer_keywords:
1010

1111
You build C# programs from these core building blocks: namespaces organize your types, types (classes, structs, interfaces, enums, and delegates) define behavior and data, and statements and expressions perform work at run time. The way you structure the entry point - where your program starts running - depends on which application style you choose.
1212

13-
The following example shows a modern C# program that uses [file-scoped namespaces](namespaces.md), [top-level statements](top-level-statements.md), and everyday C# features:
13+
The following example shows a modern C# program that uses [namespaces](namespaces.md), [top-level statements](top-level-statements.md), and typical C# features:
1414

1515
:::code language="csharp" source="snippets/toplevel-structure/Program.cs":::
1616

@@ -84,12 +84,12 @@ For detailed information about statements, see [Statements](../../programming-gu
8484

8585
Learn about these program elements in the [types](../types/index.md) section of the fundamentals guide:
8686

87-
- [Classes](../types/classes.md).
88-
- [Structs](../../language-reference/builtin-types/struct.md).
89-
- [Namespaces](namespaces.md).
90-
- [Interfaces](../types/interfaces.md).
91-
- [Enums](../../language-reference/builtin-types/enum.md).
92-
- [Delegates](../../delegates-overview.md).
87+
- [Classes](../types/classes.md)
88+
- [Structs](../../language-reference/builtin-types/struct.md)
89+
- [Namespaces](namespaces.md)
90+
- [Interfaces](../types/interfaces.md)
91+
- [Enums](../../language-reference/builtin-types/enum.md)
92+
- [Delegates](../../delegates-overview.md)
9393

9494
## C# language specification
9595

docs/csharp/fundamentals/program-structure/namespaces.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ The following example shows how namespaces work together with `using` directives
1818

1919
:::code language="csharp" source="snippets/namespaces/Basics.cs" id="NamespaceBasics":::
2020

21+
In the preceding sample, the `using` directive means you can use the <xref:System.Globalization.CultureInfo?displayProperty=nameWithType> by the name `CultureInfo` without specifying the full name of `System.Globalization.CultureInfo`. The `namespace` directive declares that the `Greeter` class is part of the `MyApp.Services` namespace. Its fully qualified name is `MyApp.Services.Greeter`.
22+
2123
## Using directives
2224

2325
Without a `using` directive, you must refer to every type by its *fully qualified name*: the complete namespace path plus the type name:
@@ -43,7 +45,7 @@ The older block-scoped syntax wraps all types in braces. This style is still val
4345
:::code language="csharp" source="snippets/namespaces/BlockScoped.cs" id="BlockScopedNamespace":::
4446

4547
> [!TIP]
46-
> Use file-scoped namespaces in new code. Most .NET templates and code analyzers recommend this style.
48+
> Use file-scoped namespaces in new code when all types in the file should be declared in the same samespace. Most .NET templates and code analyzers recommend this style.
4749
4850
## Global using directives
4951

docs/csharp/fundamentals/program-structure/preprocessor-directives.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ helpviewer_keywords:
1212
---
1313
# Preprocessor directives
1414

15-
C# preprocessor directives tell the compiler what code to include, exclude, or treat differently when it builds your app, which can change the resulting program's run-time behavior. They always start with `#` and must appear as a directive on their own line (ignoring leading whitespace), although you can add a trailing comment after the directive. While the [language reference](../../language-reference/preprocessor-directives.md) documents all available directives, four groups cover the vast majority of everyday use:
15+
C# preprocessor directives tell the compiler what code to include, exclude, or treat differently when it builds your app, which can change the resulting program. Preprocessor directives always start with `#` and must appear on their own line (ignoring leading whitespace). You can add a trailing comment after the directive. While the [language reference](../../language-reference/preprocessor-directives.md) documents all available directives, three groups cover the vast majority of everyday use:
1616

1717
- **Conditional compilation** (`#if` / `#elif` / `#else` / `#endif`) — include or exclude code based on build configuration or target framework.
18-
- **Regions** (`#region` / `#endregion`) — mark collapsible sections in your editor.
1918
- **Nullable context** (`#nullable`) — control nullable reference type analysis at a fine-grained level.
2019
- **Warning suppression** (`#pragma warning`) — suppress or restore specific compiler warnings.
20+
- **File-based apps** (`#:`) - configure file-based apps.
2121

2222
## Conditional compilation
2323

@@ -33,14 +33,6 @@ You can combine symbols with logical operators: `&&` (and), `||` (or), and `!` (
3333

3434
Use `#define` at the top of a file to define your own symbols. You can also define symbols for the entire project by using the [`DefineConstants`](../../language-reference/compiler-options/language.md#defineconstants) property in your project file.
3535

36-
## Regions
37-
38-
Use `#region` and `#endregion` to mark collapsible sections of code in your editor. Regions don't affect compilation—they're purely an organizational tool:
39-
40-
:::code language="csharp" source="snippets/preprocessor-directives/Regions.cs" id="RegionExample":::
41-
42-
Use regions to group related members. For example, you might use regions to define members of an interface when a type implements multiple interfaces.
43-
4436
## Nullable context
4537

4638
The `#nullable` directive controls nullable reference type analysis within a file. While you typically enable nullable analysis project-wide in your `.csproj` file by using `<Nullable>enable</Nullable>`, use the `#nullable` directive to fine-tune the setting for specific sections of code:

docs/csharp/fundamentals/program-structure/organizing-programs.md renamed to docs/csharp/fundamentals/program-structure/program-organization.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: "Organizing programs"
2+
title: "Program organization"
33
description: Learn how to organize C# programs using solutions, projects, assemblies, namespaces, and types to build maintainable, well-structured applications.
44
ms.date: 03/04/2026
55
ai-usage: ai-assisted
@@ -9,7 +9,7 @@ helpviewer_keywords:
99
- "namespaces [C#], organizing"
1010
- "solutions [C#]"
1111
---
12-
# Organizing programs
12+
# Program organization
1313

1414
As a C# application grows, you need a clear strategy for organizing code. .NET provides a hierarchy of organizational tools—solutions, projects, assemblies, namespaces, and types—that work together to keep large codebases manageable.
1515

@@ -53,7 +53,7 @@ By convention, namespace names follow the folder structure of your project. This
5353

5454
:::code language="csharp" source="snippets/organizing-programs/OrderService.cs" id="NamespaceMirroring":::
5555

56-
The .NET SDK supports this convention automatically. When you set `<RootNamespace>` in your project file (or accept the default, which matches the project name), the compiler uses it as the base namespace. Types in subfolders don't automatically get sub-namespaces—you declare the namespace explicitly in each file. However, following the convention makes source easier to find.
56+
The .NET SDK supports this convention. When you set `<RootNamespace>` in your project file (or accept the default, which matches the project name), the compiler uses it as the base namespace. Types in subfolders don't automatically get sub-namespaces—you declare the namespace explicitly in each file. However, following the convention makes source easier to find.
5757

5858
## Choosing how to split namespaces
5959

docs/csharp/fundamentals/program-structure/top-level-statements.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,17 @@ helpviewer_keywords:
88
---
99
# Top-level statements - programs without `Main` methods
1010

11-
You don't have to explicitly include a `Main` method in a console application project. Instead, you can use the *top-level statements* feature to minimize the code you have to write.
11+
You can use the *top-level statements* feature to minimize the code you have to write. You don't have to explicitly include a [`Main` method](./main-command-line.md) in a console application project.
1212

13-
Top-level statements allow you to write executable code directly at the root of a file, eliminating the need for wrapping your code in a class or method.
14-
This means you can create programs without the ceremony of a `Program` class and a `Main` method.
15-
In this case, the compiler generates a `Program` class with an entry point method for the application. The name of the generated method isn't `Main`, it's an implementation detail that your code can't reference directly.
13+
Top-level statements allow you to write executable code directly at the root of a file, eliminating the need for wrapping your code in a class or method. This means you can create programs without the ceremony of a `Program` class and a `Main` method. In this case, the compiler generates a `Program` class with an entry point method for the application. The name of the generated method isn't `Main`, it's an implementation detail that your code can't reference directly.
1614

1715
Here's a *Program.cs* file that is a complete C# program:
1816

1917
```csharp
2018
Console.WriteLine("Hello World!");
2119
```
2220

23-
Top-level statements let you write simple programs for small utilities such as Azure Functions and GitHub Actions. They also make it simpler for new C# programmers to get started learning and writing code.
21+
Top-level statements let you write simple programs for small utilities such as Azure Functions and GitHub Actions. They provide a natural evolution as file-based apps grow to include more files.
2422

2523
The following sections explain the rules on what you can and can't do with top-level statements.
2624

docs/csharp/toc.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ items:
4141
href: fundamentals/program-structure/namespaces.md
4242
- name: Preprocessor directives
4343
href: fundamentals/program-structure/preprocessor-directives.md
44-
- name: Organizing programs
45-
href: fundamentals/program-structure/organizing-programs.md
46-
- name: Main method
47-
href: fundamentals/program-structure/main-command-line.md
44+
- name: Program organization
45+
href: fundamentals/program-structure/program-organization.md
4846
- name: Top-level statements
4947
href: fundamentals/program-structure/top-level-statements.md
48+
- name: Main method
49+
href: fundamentals/program-structure/main-command-line.md
5050
- name: Type system
5151
items:
5252
- name: Overview

0 commit comments

Comments
 (0)