Skip to content

Commit 5f0bc6f

Browse files
committed
Fixes #42858
Add an explanation on declaring variables in top level statements.
1 parent 203b690 commit 5f0bc6f

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

docs/csharp/tutorials/top-level-statements.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ Should I use top level statements in all my programs?
100100
Better not tell you now.
101101
```
102102

103+
The code to generate an answer includes a variable declaration in your top level statements. The compiler includes that declaration in the compiler generated `Main` method. Because these variable declarations are local variables, you can't include the `static` modifier.
104+
103105
This code answers the questions, but let's add one more feature. You'd like your question app to simulate thinking about the answer. You can do that by adding a bit of ASCII animation, and pausing while working. Add the following code after the line that echoes the question:
104106

105107
:::code language="csharp" source="snippets/top-level-statements/UtilitiesPassOne.cs" ID="AnimationFirstPass":::

0 commit comments

Comments
 (0)