Skip to content

Commit 546ce89

Browse files
Fix snippet - ConsoleKey1.cs (#9009)
Fix the sample output for the snippet in ConsoleKey1.cs to match the code.
1 parent 54e47bf commit 546ce89

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

snippets/csharp/System/ConsoleKey/Overview/ConsoleKey1.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ public static void Main()
1616
String.Format("You pressed {0}", input.Key.ToString()));
1717
bool modifiers = false;
1818

19-
if ((input.Modifiers & ConsoleModifiers.Alt) == ConsoleModifiers.Alt) {
19+
if (input.Modifiers.HasFlag(ConsoleModifiers.Alt)) {
2020
output.Append(", together with " + ConsoleModifiers.Alt.ToString());
2121
modifiers = true;
2222
}
23-
if ((input.Modifiers & ConsoleModifiers.Control) == ConsoleModifiers.Control)
23+
if (input.Modifiers.HasFlag(ConsoleModifiers.Control))
2424
{
2525
if (modifiers) {
2626
output.Append(" and ");
@@ -31,7 +31,7 @@ public static void Main()
3131
}
3232
output.Append(ConsoleModifiers.Control.ToString());
3333
}
34-
if ((input.Modifiers & ConsoleModifiers.Shift) == ConsoleModifiers.Shift)
34+
if (input.Modifiers.HasFlag(ConsoleModifiers.Shift))
3535
{
3636
if (modifiers) {
3737
output.Append(" and ");
@@ -49,23 +49,23 @@ public static void Main()
4949
}
5050
}
5151
// The output from a sample console session might appear as follows:
52-
// Press a key, along with Alt, Ctrl, or Shift.
52+
// Press a key, together with Alt, Ctrl, or Shift.
5353
// Press Esc to exit.
5454
// You pressed D.
5555
//
56-
// Press a key, along with Alt, Ctrl, or Shift.
56+
// Press a key, together with Alt, Ctrl, or Shift.
5757
// Press Esc to exit.
58-
// You pressed X, along with Shift.
58+
// You pressed X, together with Shift.
5959
//
60-
// Press a key, along with Alt, Ctrl, or Shift.
60+
// Press a key, together with Alt, Ctrl, or Shift.
6161
// Press Esc to exit.
62-
// You pressed L, along with Control and Shift.
62+
// You pressed L, together with Control and Shift.
6363
//
64-
// Press a key, along with Alt, Ctrl, or Shift.
64+
// Press a key, together with Alt, Ctrl, or Shift.
6565
// Press Esc to exit.
66-
// You pressed P, along with Alt and Control and Shift.
66+
// You pressed P, together with Alt and Control and Shift.
6767
//
68-
// Press a key, along with Alt, Ctrl, or Shift.
68+
// Press a key, together with Alt, Ctrl, or Shift.
6969
// Press Esc to exit.
7070
// You pressed Escape.
7171
// </Snippet1>

0 commit comments

Comments
 (0)