Added information about the Console.ReadKey() (#21922)
This commit is contained in:
committed by
Christopher McCormack
parent
75e37f952b
commit
1be36da043
@ -1,35 +1,37 @@
|
||||
---
|
||||
title: Hello World
|
||||
---
|
||||
|
||||
# Hello World
|
||||
|
||||
To write some text on the console we use the `Console.WriteLine()`. This method takes a string as input and has a return type of `void`.
|
||||
|
||||
## Example
|
||||
```csharp
|
||||
using System;
|
||||
|
||||
namespace HelloWorld
|
||||
{
|
||||
class Hello
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
// Write "Hello World!" on console
|
||||
Console.WriteLine("Hello World!");
|
||||
|
||||
// Keep the console window open in debug mode.
|
||||
Console.WriteLine("Press any key to exit.");
|
||||
Console.ReadKey();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Output:
|
||||
```sh
|
||||
> Hello World!
|
||||
> Press any key to exit.
|
||||
```
|
||||
---
|
||||
title: Hello World
|
||||
---
|
||||
|
||||
# Hello World
|
||||
|
||||
To write some text on the console we use the `Console.WriteLine()`. This method takes a string as input and has a return type of `void`.
|
||||
|
||||
The method `Console.ReadKey()` waits for a user to press any key.
|
||||
|
||||
## Example
|
||||
```csharp
|
||||
using System;
|
||||
|
||||
namespace HelloWorld
|
||||
{
|
||||
class Hello
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
// Write "Hello World!" on console
|
||||
Console.WriteLine("Hello World!");
|
||||
|
||||
// Keep the console window open in debug mode.
|
||||
Console.WriteLine("Press any key to exit.");
|
||||
Console.ReadKey();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Output:
|
||||
```sh
|
||||
> Hello World!
|
||||
> Press any key to exit.
|
||||
```
|
||||
|
Reference in New Issue
Block a user